Summary:

Generally, a ranged unit must be able to "see" its target in order to be able to fire at it (with the exception of units with the "Indirect Fire" promotion). A unit cannot see a target if a blocking object is between the two - a mountain or hill, for example, or a forest tile. A unit can always see into a tile, even if it contains blocking terrain, but it cannot see objects in tiles past the blocking terrain. Note that units on hills and flying units can often see over blocking terrain.