BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Project Catalyst Brings iOS Apps to macOS

Project Catalyst Brings iOS Apps to macOS

Leia em Português

This item in japanese

Apple recently announced project Catalyst during its WWDC. Catalyst, also known as Marzipan, is designed to allow developers to release iOS apps for macOS, starting with the next major release of macOS Catania.

Last year, Apple started porting some iOS apps to macOS using the project Catalyst, such as Voice Memos, Apple News, Stocks and Home. Now, Screen Time is coming to macOS, as well as some new iOS 13 features, such as new Reminders app, photo gallery, folders in Notes.

Some companies also announced they will bring their apps to macOS, such as Twitter, Gameloft, Atlassian, DC, among others.

(Image taken from blog.twitter.com)

Project Catalyst gives developers an easy path for porting their iPad apps over to macOS. By default, the macOS version of an iPad app supports window resizing and full-screen display; trackpad, mouse, and keyboard input; copy/paste, and drag and drop; touch bar controls; a default menu bar, and Mac style scroll bars. Developers can, however, do a little bit of extra work in order for their apps to fit better on macOS with things like menu bar controls, toolbar shortcuts, and translucent sidebars.

To get started porting an iPad to macOS, first of all, developers need to install XCode 11 beta, then open the Xcode project and select the iOS target that they want to configure. Then they should go to General tab > Deployment Info, and click the checkbox for the Mac device (if your app supports iPhone only, the checkbox is unavailable).

After selecting Mac as a supported device, Xcode will make the following changes to your project:

  • Add a bundle identifier for the Mac version of the app
  • Add the App Sandbox Entitlement (a Boolean value that indicates whether the app may use access control technology) to your project
  • Add My Mac to the list of destinations that can be chosen when running your app from Xcode
  • Excludes incompatible frameworks, app extensions, and other embedded content

Although Xcode excludes incompatible frameworks and embedded content where possible, at times it's necessary that developers exclude some content manually. To do so, go to the General tab for the iOS target > Frameworks > Libraries > Embedded Content. Then select iOS as the platform setting for the item. This setting excludes the item from the Mac version of your app.

For projects that contain code that no longer compiles because of frameworks or APIs that are unavailable to the Mac, it's possible to enclose it as shown here:

#if !targetEnvironment(UIKitForMac)
// Code to exclude from Mac.
#endif

It is possible to use the same approach to include a framework that is available only in macOS.

#if targetEnvironment(UIKitForMac)
// Code to execute only on Mac.
#endif

Although most iPads apps are great candidates for macOS, apps whose essential features require gyroscope, accelerometer, rear camera, iOS frameworks like HealthKit or ARKit, or whose main function is something like navigation, are probably then not suited for macOS.

More details about Catalyst can be found at the Apple developer site. Xcode 11 beta is available for download at https://developer.apple.com/download/. There is also a development guide available.

Rate this Article

Adoption
Style

BT