Once more nations get most of their Air Force equipped with stealthy aircraft, then yes the gun is still going to be needed.
In Vietnam, the problem assumed in the Phantom was that most combat would be BVR. Which would have been accurate in the event of a US v USSR fight. But when you have USN, USAF, USA, RAAF, ROKAF, ROKA, RVNAF, ARVN etc all flying overhead and you don't have reliable IFF systems, you need to get positive visual ID to avoid fratricide. And now you're close enough to need guns.
When only one side in a conflict has LO aircraft, they control the range at which the fights happen. And it'll be overwhelmingly BVR. Once both sides in the fight have LO aircraft, we're looking at WVR (or pretty close to that using IRSTs). So you're going to need guns again.