There are other questions addressing how casting attack spells while hidden blows your cover, but what if you are out of the range of perception for the target?
Some additional background: based on the DM screen, the typical range of sound perception is 35' for people trying to be quiet, 70' for normal volume, and 350' for loud sounds. Firing a longbow creates a sound that's ~90 dB and sound drops off rapidly with the square of distance. By 90', the sound would be no louder than a close distance conversation. At maximum longbow range it would be quieter than any ambient noise.
If I have 120' dark vision range and cast a spell at someone at that range without dark vision (which is "normal" sound), there would seem to be no way they can perceive me and thus reveal my location. Even though I would "no longer be hidden" that only applies to individuals near enough to either hear or see me. Depending on the spell, they might be able to intuit a direction for the attack but not a clear source. Some spells (Chill Touch, for example) create a visual effect at range but do not provide a clear visual link between the spell effect and the caster.
Would a setup like this potentially allow for "spell sniping" someone in the dark without revealing your location?