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 Cpmear, the mean power coefficient over eight periods, fluctuates slightly with µx, and the maximum fluctuation of Cpmear is less than 4%. Therefore, the time-varying freestream velocity slightly affects the total energy harvesting efficiency for a lengthy period.