Shrewdly, Apple got them to do a lot of the cross-platform heavy lifting over the last two years bringing the core of both to the massive installed base of iPhones and iPads. New subscription-based revenue models didn't hurt either.
Ironically, porting to iOS doesn’t buy you as much here as you might think.
Yes, it flushes out
some of the issues that are there early, but those are generally smaller problems compared to writing a new UI layer against UIKit after writing against AppKit and something similar to Carbon before it. And any features you cut from the iOS version because they don’t make sense, or violate some App Store rule, you still need to support on the Mac.
The push to get developers 64-bit clean on macOS probably did more heavy lifting in this case. That forced these projects to grapple with the sort of issues that also happen to plague an ISA change (data alignments, etc). Apple’s changes to AppKit over the years to support 64-bit also happen to make it a lot easier for code to survive an ISA change so long as you aren’t writing custom inline assembly (which also probably isn’t as common as you might think these days).