Bringing a macOS App to iOS

Lessons learned while developing Kaleidoscope for iPad.

Emlyn Murphy
BPXL Craft
Published in
4 min readNov 2, 2017

--

We recently ported Kaleidoscope, our beloved Mac application, to the iPad. iOS 11’s productivity features, such as drag and drop and enhanced multitasking, made it a natural fit for the tablet. Given the task of attempting such a port, we had to first determine the most important things to consider for making it a smooth transition.

When the iPhone was originally announced, Steve Jobs delivered the exciting news that it ran OS X. Although the iPhone and other related devices’ operating system names and features would change over time, they have a shared heritage that reduces the complexity of porting applications from macOS to iOS. While the UI paradigms are somewhat different between the platforms, the vast majority of frameworks and tools are the same. However, there were important factors regarding the UI and shared code that required careful attention.

Overhauling the UI Design

The main difference between macOS and iOS apps is that macOS uses AppKit for its UI framework and iOS uses UIKit. AppKit incorporates concepts like overlapping windows, menus, and a mouse pointer. UIKit includes Multitouch and a single window that changes depending on the application’s state and context. Apple chose to create a new UI framework for iOS, because of the major UI paradigm differences between the two platforms. For this reason, when creating the iOS version of your Mac app, the design of your UI will require an overhaul. You should create a new UI design for your app that feels native on iOS and uses its idioms.

Beware the temptation to create or use an existing cross platform UI framework. Not only is this difficult to get right, but future OS versions may break your framework, which would require ongoing maintenance. In the end, you will most likely get worse results with more work by attempting to make your UI cross platform. Apple made two separate UI frameworks for a reason.

Creating a Framework for Shared Code

The part of your application that will contain shared code is the model that describes your application’s data and behavior in a UI-independent manner. If you didn’t design your application this way, then you’ve got some work to do. Even if you attempted to create a clean model, you will most likely discover places that need some work.

The best way to share code is to create a framework. You will need to create separate targets for macOS and iOS versions of your shared framework. Usually a good naming scheme for your framework targets is something like MyAppCore-macOS and MyAppCore-iOS. You will also need to create a new iOS application target. Both of your application targets need to have the corresponding shared framework targets assigned as a target dependency, need to be linked against it, and need to be included in the embed frameworks phase.

Identifying Files for the Shared Framework

Next you will begin the hard work of identifying which source code files should be part of your framework targets. Both framework targets should contain the same list of source code files and those files should be removed from your Mac application target. Prime candidates for inclusion in your shared framework are data model files like Core Data classes, network clients, utility classes, and any other part of your app that you can separate from the UI and reuse. One way to find your application’s UI independent code is simply to check each source code file’s imports for the absence of UIKit.

Unit Testing for Improved Reliability

If you have a lot of behavior defined in view controllers, then you’ll need to refactor that behavior into separate data types that are used by your existing view controllers. When your model is cleanly defined and uncoupled from the UI, your shared framework will be a great candidate for unit testing. Your model is the most important part of your application, and adding unit tests will confirm that it is working correctly. Unit tests will also help to minimize bugs when you make changes.

An Almost-Perfect Fit

Applications created for macOS may seem like a natural fit for iOS; much of your application’s logic and data model can be shared between platforms. But don’t overlook these important details. Your biggest challenge will be creating a clean architecture that separates your application’s model from its UI. Rethink and reimplement your application’s UI in iOS’s UIKit and you’ll be well on your way to making a smooth transition from macOS to iOS.

Download Kaleidoscope for iPad on the App Store, try it out for free for 14 days, and let us know what you think.

Black Pixel is a creative digital products agency. Subscribe to BPXL Craft and follow us on Twitter.

--

--