Homemade Marzipan Recipes: UIKit on macOS

Well, we are definitely going to accept credulously everything Mark Gurman tells us from now on, because he called it six months early: Yes, UIKit is coming to macOS, and it is, in fact, code named “Marzipan”— top marks! And there’s been a wide range of reactions to that, the best collected (as usual!) over at Michael Tsai’s blog:

Apple Announces Marzipan for 2019

One particularly notable contrarian voice can be found at Apple Didn’t Kill AppKit, Millenials Did:

But here’s the painful part: the techniques to do these things are already available, well-known, and very few people are using them. There are still lots of iPhone-only apps, or apps that make poor use of the iPad and just let their table views stretch out to infinity. And as for tvOS… it already runs UIKit. Your scenes are actual damn UIViewControllers. And yet look at the dearth of TV apps. We’ve had Marzipan on the TV for years and almost nobody uses it…

Well yes, that’s a good argument, and yes, it’s not all that hard to make a UIKit+AppKit app now if you want to, 

To be clear, the enemy is not other Apple-platform developers. The enemy is the use of bloated, cross-platform, phone-it-in frameworks. “Write once, run everywhere” has been promised and come up wanting for decades: Java applications and applets, Adobe AIR, Xamarin, PhoneGap, and so on. One semi-success story of recent years are the various approaches like Electron and Chromium, which effectively embed an entire instance of the Chrome web browser in an app wrapper. This approach is used by such Mac apps as Slack, Discord, and Spotify.

It is also a goddamned scourge, and straight up an abuse of the end-user’s equipment.

And yes, yes, that too.

However, none of these objections are particularly subtle, and yet Apple’s put a couple years so far into this and is doubling down. All in order to save, spitballing here, maybe 15-25% of any well-architected app would need to be different? Well, that makes people figure, also quite reasonably, that the real agenda here is to support the ARM Macs That Everyone Expects Sooner Or Later:

Marzipan as a Path to ARM Based Macs

What if MacOS on ARM only ran these new UIKit apps?

That’s a scary thought for this MacOS developer.

But then again, we already have this and it’s called iOS on the iPad. And maybe, just maybe, and remember these are half baked thoughts, but maybe Apple is wondering if some Pro users might be better served by MacOS Touch 1.0 running on ARM.

An interesting perspective. But, as announced, Apple is using it themselves, so we know that they evaluated the cross-platform strategy ably ranted on behalf of above, and they decided it made more sense to engineer this Grand UIKit Emulation Layer … well, for some reason. Be fascinating to find out what next year or two!

In the meantime, what’s shipping now is surprisingly functional, people are finding:

and although it’s generally agreed that you shouldn’t pay too much attention to the current implementation details, if you want to have some quick fun:

marzipanify

marzipanify is an unsupported commandline tool to take an existing iOS Simulator binary (with minimum deployment target of iOS 12.0) and statically convert it and its embedded libraries & frameworks to run on macOS 10.14’s UIKit runtime (Marzipan)…

MarzipanTool  — Port an iOS app to macOS 10.14 in 5 minutes

Here’s how to port your iOS apps to macOS 10.14 Beta using Apple’s iOSMac/Marzipan framework. A “Hello World” iOS app can become a macOS app in less than 5 minutes. (I timed it.).

Marzipan Platter

At WWDC 2018 Apple announced that they are working on a multi-year strategy to make it easier to port UIKit applications to the Mac. While some first-party applications such as the Home & News app are going to use this API in macOS 10.14, third-party developers won’t have official access for another year. As a result, I made this project to help tinkerers/other impatient people get a taste of what’s to come when Apple gives everyone access to Marzipan next year…

Marzipan – UIKit on macOS

For this post I prepared a very simple app — that allows you to fetch top stories from Hacker News and present them in a simple UITableView. This app is simple as far as functionality is concerned but includes some standard plumbing and networking to see whether common libraries can be used on macOS. The good news is that this is indeed possible and we can use libraries like Alamofire, Swinject and others without any special effort!

So, it doesn’t take too much to figure that Marzipan is going to be extremely important in the not so distant future … get started today!

But please, don’t do what this guy did, even tongue in cheek and all…

Marzipants

Here’s a proof-of-concept that React Native can work* (*lol) under Marzipan.

But, like, it’s proof that we don’t need Electron, right? 💪

… It’s surprising how well it’s working. Besides the obvious mobile-specific things, it’s running abouuuut as well as tvOS builds of React Native.

I wouldn’t recommend using it. Ever. C’mon now.

Alex | July 6, 2018

Leave a Reply