Anupam Chugh
Oct 9 · 3 min read
From WWDC — this all you really have to do in order to port iOS to macOS

Coming from an iOS background, I always wanted to build macOS apps.

For some reason, though, I was a little hesitant in taking a deep dive into the OS X and the AppKit framework. The fact that the Mac App Store is relatively small was just one of the reasons.

Fortunately, now thanks to Project Catalyst, we can port iOS- and UIKit-based apps to macOS easily.

The convenience that Catalyst offers in porting apps from one platform to another would encourage and bring developers back to Apple’s ecosystem.

It took me literally just five minutes to port one of my iOS Projects — which we shall see in this article.

Did you know?
Project Catalyst was initially code-named as Marzipan.

Prerequisites

  • You need Xcode 11
  • You need Mac Catalina 10.15

Steps

  • Go to Project Navigator | General Tab, and just enable the macOS checkbox
  • Go to Signing and Capabilities, and enable any permissions (e.g., file read/write) you need to for your use case
  • Just build it with Mac set as the target

Under the Hood

What happens when you enable Mac support?

When you enable Mac support, a new bundle identifier for the macOS app is created. The new ID is just a prefix (maccatalyst) to the older iOS bundle identifier.

Xcode adds two capabilities, namely: hardened runtime and app sandbox.
Moreover, Xcode takes care of updating the entitlements file with the necessary information from the info.plist.

One big improvement with Catalyst is a single unified Apple developer certificate across platforms. Say goodbye to separate iOS and macOS certificates.


Our First macOS App Using Catalyst

We’ll be porting our vision-based animal classifier iOS project, which we had covered in a previous article, to our macOS application.

Since our application requires accessing images from the photo library, we need to allow the pictures folder access from the capabilities section.

Setting the pictures folder access to read-only in order to pick images

It’s time to run our macOS application. Below is what we see:

A look at our ported macOS app for Cat vs. Dog Classifier

That sums up this article. You can view the source code that works on both Mac and iOS from our Github Repository.


Better Programming

Advice for programmers.

Anupam Chugh

Written by

I develop apps and write about them. Blogging weekly at iowncode.com 🇮🇳

Better Programming

Advice for programmers.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade