The hydrokinetic turbine, using an oscillating foil to extract tidal energy, offers an obvious advantage in shallow water. The software Fluent is used to solve the 2D unsteady incompressible Navier-Stokes equations around an oscillating foil with computations performed with using NACA0015 foil. The parameter μx which indicates the oscillation frequency ratio between the freestream and foil motion, is introduced to identify the effects of time-varying freestream velocity. The mean power coefficients are examined over one period and eight periods, the force evolution is reviewed, and the flow fields around foil are analyzed. The results indicate that time-varying freestream velocity leads to fluctuation of the cycle-averaged power coefficient CP¯, with the maximum fluctuation of CP¯ exceeding 16%. A similar variation trend is observed for CP¯ versus μx under different motion parameters. Furthermore, it is found that CPmean, the mean power coefficient over eight periods, fluctuates slightly with μx, and the maximum fluctuation of CPmean is less than 4%. Therefore, the time-varying freestream velocity slightly affects the total energy harvesting efficiency for a lengthy period.