How many swords are there relative to human standing militaries? Are there enough swords for entire human militaries across the world to replace guns?
I would assume that the likely answer is no.
Why would a near future society/humanity still use guns mainly in their military against both humans and other entities, when these swords grant users such power?
Humans will likely adopt the use of said magical swords, but its limited amount plus difficulty training people in swordsmanship make it not suitable for regulars. Instead, a small group of soldiers will be trained to wield these swords and be embedded to the main army roster in various ways.
1. Reconnaissance, intelligence, espionage Hyperspeed and/or teleportation, regeneration, heightened reaction/perception? This combo screams "perfect spy/scout".
2. Assistance in transport or evacuation Again, hyperspeed and/or teleportation? Although sword wielders can only use these capabilities sparingly, at least they can be instructed to do so only for critical situations (e.g. Dunkirk or D-Day).
3. One-man engineer corps They can make damage comparable to artillery strikes once in a while with their area-of-effect attacks. Having them augmented in a regular infantry corps roster is useful.
4. One-off recharge-limited supersoldier Occasionally, an infantry team runs into an unexpected encounter with an enemy larger team. Magic swordwielders can Hulk up their power for a short time, banishing and fighting the enemy into the mirror dimension, saving the team from surrender or destruction.
Humans will still use guns as standard-issue soldier kit. Yes, the swords will be used partially, but it won't replace rifles. Why?
1. Easy training People can be trained well to use firearms faster than swords. 523
Duck-and-cover and return-fire discipline is also (presumably) easier to instill than sword combat disciplinecitation needed. Even with all the skills, it's still a sword to wield.
2. Easy production Guns can be made in large amount (and so the number of people available to use them). There are just times when quantity with slight quality wins over slight quantity with pure quality.
3. Previous popularity Guns and the accompanying current 'conventional' toys of war have been used extensively in recent history in comparison to these new swords. It will be easier for militaries to develop ways to either improve, patch, or extend the already existing roster of tools and systems. It takes time to study how to best use these swords, especially now that we have other very powerful weapons that we're already fluently brandishing now and then. No one rushes to mass-adopt them. Likely, adoption will be a very long process given the limited number of items. Some of militaries will just adopt them for the sake of leveling the playing field and not to prioritize its usage.
4. Near stigma-free Given its popularity and mainstream use, no one will brand a gunman "witch" or "sorcerer". Contrast with this new rising magic. It's very easy for an enemy nation to call a nation with major use of these swords "using an army of entirely 'dark magic'-ians", sort out a PR work to stamp it as 'Axis of Hell', produce both local and global consent to gang up against it, then just wipe it out. 523