Lets say I am attacking a foe with a magic bow and and I have the Sharpshooter feat. If he has immunity against non magical weapons, does the +10 damage from sharpshooter still apply?
The damage type from Sharpshooter delivered to a creature is based on the weapon that delivers that damage.
Wizards of the Coast have confirmed via the official Sage Advice Compendium that mundane ammunition fired from a magic weapon delivers magical damage (see the answer to "My fighter attacks a creature with a magical longbow and nonmagical arrows. Is the attack magical?").
The attacks made by a magical ranged weapon are magical, even if the ammunition isn’t magical.
Additionally, we have the rules on critical hits(PHB, 196) which state:
For example, if you score a critical hit with a dagger, roll 2d4 for the damage, rather than 1d4, and then add your relevant ability modifier. If the attack involves other damage dice, such as from the rogue's Sneak Attack feature, you roll those dice twice as well.
While Sneak Attack isn't the sharpshooter feat, the language is similar and strongly suggests that the damage from sharpshooter is an extension of damage from the weapon. In this case, it is magical piercing damage.