Normal magi cannot use spell combat with a ranged weapon.
Eldritch archers and myrmidarchs can use spell combat with a ranged weapon, but cannot with a melee weapon.
No magus of any type can use spell combat with both melee and ranged weapons.
Thus, you are basically incapable of properly using magus class features with both of these weapons at once.
What’s more, the firearm rules in Pathfinder are pretty much awful, and unless you are a gunslinger (or some firearm-focused archetype, of which the magus has none), you have basically no hope of using them affordably or reliably. The ammunition is exceedingly expensive and the guns themselves break far too often. Even if you were a gunslinger, they’re still really problematic even after all your class features are dedicated to making them not suck.
And reloading with a sword in your hand is extremely difficult, unless you go and get extra arms.
Finally, ranged combat requires a lot of feats, but so does two-weapon fighting. Getting both on magus, which does not receive very many bonus feats, is going to be very difficult.
But, if you still wish to pursue this idea, a Spellslinger 1/Eldritch Archer 19 can... just about do what you want by jumping through a lot of hoops.
With a nod to Nickmagus for pointing it out, the spellslinger wizard archetype is critical here. Your first level basically has to be that; you get a free gun or two, as well as the critical Gunsmithing feat. Arcane gun is also strictly superior to ranged spellstrike, since it works with spells from any class and it works with more spells than just those that involve a ranged attack.
As if that wasn’t enough, wizards also get abundant ammunition and fabricate bullets as 1st-level spells that magus doesn’t get at all. That means your one level in spellslinger can get you both. Abundant ammunition’s duration of 1 minute/level is long enough at 1st level to be useful, while even if you had more caster level it still wouldn’t be too much better. The Magical Knack and Precocious Spellcaster traits can increase its caster level by 2 (but not higher than your total level) and 1, respectively. Using both traits this way might be overkill though; there are some really good traits out there. Extra Traits is a pretty good feat, but you need too many feats to afford it.
After one level of spellslinger, switch to magus. Here I diverge from Nickmagus; kasantha solves a ton of problems, but it ultimately just doesn’t seem satisfying. You can avoid the need for an extra arm somewhat by using the eldritch archer magus archetype; the ranged spell combat feature of eldritch archers includes this wonderful line:
She doesn’t need a free hand for ranged spell combat.
This does mean you get ranged spellstrike, instead of the regular version you could use with your sword. That’s deeply disappointing, since arcane gun already covered your ability to attack with a ranged weapon through a spell, and there’s no way to get regular spellstrike now. So your sword will never carry a spell.
The other thing you have to worry about is this mess:
Instead of a light or one-handed melee weapon, an eldritch archer must use a ranged weapon for spell combat.
As a full-round action, [a magus] can make all of his attacks with his melee weapon at a –2 penalty and can also...
Basically, the implication here is that you can only use one weapon with spell combat, which might imply that it cannot be combined with two-weapon fighting and that you can’t even switch to a different weapon with e.g. an iterative attack.
It also means that you have to be attacking with a ranged weapon for it to “count” as ranged spell combat. This is problematic because the ideal case for you is to attack with your sword and cast a spell through spell combat, which you then fire a gun through using arcane gun or ranged spellstrike.
My solution is to use a weapon that can be thrown, like a dagger, as your “sword.” If you really want a “sword” specifically, you could use a throwing weapon; that’s a +1-equivalent special magic weapon property that turns pretty much anything into a throwable weapon. Before you can afford that, I recommend just using a dagger or even a trident. You don’t need returning since you probably won’t ever actually throw it, it just needs to be a ranged weapon for ranged spell combat.
So now you can go into ranged spell combat with your throwable sword as the “ranged weapon” you “must use [...] for spell combat,” and then when you cast a spell, you can use arcane gun or ranged spellstrike to shoot your pistol through it. I’m going to assume that the attack through the spell does not also need to be with the same weapon as the rest of your attacks with spell combat; this is not necessarily clear or even true, so check with your GM.
Until you are a 4th-level magus, you basically can’t reload in combat. You don’t have enough hands; you’d have to sheathe your sword and then reload your pistol, spending a whole turn doing it, and then the next turn you’d have to draw your sword again (and if you fire your pistol while doing that, it needs to be reloaded again). This sucks, but I can find no way around it (aside from getting more arms).
However, once you get 2nd-level spells, reloading hands reloads one pistol once per round without using any action on your part or either of your hands. Huzzah, now you can continue doing your spell combat thing and shooting, since you get one shot per round which nicely matches up with the one spell you get each round.
Reloading hands nicely takes care of the action requirements on reloading, but you still need to have attacks available to use any of this.
At this point, I’d like to point out how lucky you are that reloading hands is a magus spell. As a 2nd-level spell, it would be prohibitive to get as a wizard spell, but reloading hands is literally the only magus spell in Pathfinder to mention firearms.
Ironically, because you are only ever attacking once per round with your pistol, through the spell, and you are relying on reloading hands anyway, you can skip a ton of otherwise-critical feats. You don’t need Rapid Shot or Two-Weapon Fighting (your pistol wouldn’t be loaded for those attacks anyway), you don’t need Rapid Reload, and so on.
The one feat that you absolutely need is Weapon Finesse, because there’s just no way you can manage to have decent Strength and Dexterity and Constitution and Intelligence. Even just three is really hard. So Weapon Finesse is a must; use effortless lace if your weapon would not ordinarily qualify for it. If third-party material is allowed, Deadly Agility might be worthwhile since it will add Dexterity to your damage with that sword, too.
There’s also a Sword and Pistol feat, which is incredibly expensive, and ultimately not that useful to you. What it does is allow you to shoot your pistol while someone threatens you, without provoking that person. The problem is, your spellcasting still provokes, so you don’t really get out of things and still need to step away to cast your spell/make your attack.
Things change massively if you manage to reload faster, however. You could, for example, take Quick Draw so you could draw the second arcane gun and keep shooting. That could potentially be four shots, if you have reloading hands on each gun. In order to get attacks for those shots, though, you need Rapid Shot and/or Two-Weapon Fighting, which poses a few major problems:
you take huge attack penalties, up to −6 with those and spell combat, on a ¾ BAB class that has a dip in a ½ BAB class,
you need an enormous number of feats,
you have to do something with the pistol you shot twice before you can draw the second one, and the only thing you can do with it fast enough is drop it to the floor, which causes obvious problems when you consider just how expensive it will be to replace if you don’t get a chance to collect it again, and
you may not even be able to combine spell combat with two-weapon fighting in the first place.
What you end up with here is 1-3 attacks, depending on BAB, with a sword, one spell cast, and potentially one pistol shot included in the spell. You’ll have abundant ammunition, fabricate bullets, and reloading hands to keep your gun ready to go, though you have almost no solution to misfires. Your damage will be pretty low, since you can’t get 1½×Str to damage as with a two-handed weapon but you aren’t getting a bunch of extra attacks as with a pure-ranged build or with true two-weapon fighting, and you have no bonus damage to add to those in any event.
Notably, a single shot with a pistol adds very, very little damage here. Pistols are low-damage options to begin with. This build jumps through an awful lot of hoops to add that one shot to your repertoire; without it we could just be a straight magus who just casts ranged-attack spells instead of making a lot of spellstrikes (but we’d still have spellstrike if we wanted it), doing exactly the same thing minus the pistol’s minor damage.