The thing is, even if Guns replace magic in terms of commonality on the battlefield as a weapon, they would not replace magic for all the other aspects of both life and warfare. Mass communication, scrying, resource manufacture, transportation, terrain alteration, visibility cover, defensive cover, illumination, crowd control, healing and triage, spying and counter-intelligence, illusions to hide troop placement, troop morale/performance enhancers, weapon enhancement/enchantment (now you can turn shitty flintlocks into magic sniper rifles for specialists), weather manipulation, cover creation, smokescreens, enhancements to cavelry such as magically created mounts, quick troop creation, siege warfare, etc.
And tha's only the military application. Next you have to conside how the existance of magic and magical items will effect the economy, how their supply and demand will be determined, who has the right to create and sell magical items, rates for wizards to charge magical services and how that in turn affects auxiliary markets, item availablility, political sway the mages and potential guilds my have, overall quality of life for the citizenry, how pay rates will be altered by this market, how magic will effect safety and worksman benefits, corporate espionage, the potential cost of automation with golems vs traditional workers, and the millions of other factors.
Heck, even with some basic maical spells and effects, society and the needs of it can be changed drastically if not addressed by an in-universe reasons. Decanter's of Endless Water, Pearls of Purity, Create Food and Drink, Rings of Sustanance all majorly effect basic resource needs of people, and all that you need to created a near-perpetual electric generator is a simple Ring of Gates pair, which a smart wizard would black-box, patent, and sell to people and live as a rich fatcat from his royalties, rent/use fees, and occasional maintainance fees.
Guns won't erase magic, they'll complement it