Marzipan : we ported our iOS app to the Mac in an afternoon

The WWDC 2019 would be-it already over ? One may ask the question in the view ports of iOS apps to the Mac, which bloom already. While Apple has planned to unveil more details next month Marzipan, the community was not expected.

Guided in particular by the pioneer of engineering Steven Troughton-Smith, the third-party developers are experimenting with the conversion of their mobile apps to the desktop system. It is able to confirm to you that it works : our iOS app iGeneration is running like a charm on Mac.

Of Marzipan…

A little reminder on Marzipan is necessary. Marzipan, this is the code name of the project, which aims to make it available on macOS-framework UIKit to build iOS applications. UIKit is an application framework that form the top layer of the system, which manages the way applications react to the demands of the system and the user. Summary very briefly, it allows you to create a dynamic interface.

macOS had its own application framework, AppKit, which remains the framework by default. UIKit is a supplementary tool available to developers. The project Marzipan allows the end of the account to the iOS developers to easily port their applications to macOS.

At WWDC 2018, Craig Federighi presented the main lines of the draft, and gave appointments to the following year for the details and the tools used to accomplish the porting.

Apple has started to adapt UIKit, a framework originally designed for a touchscreen use, a desktop environment (support mouse, scroll bars, drag-and-drop, etc).

Apple has even delivered the appetizers in macOS Mojave. The new in-House applications, Stock market, Voice memos, and News are taken from the project Marzipan : these are ports of the iOS versions. It was not necessary any more for the developer Steven Troughton-Smith manages to create her own “converter” apps, iOS apps, macOS — this is not the only one, but it is the most advanced.

… to marzipanify

By a work of retro-engineering, detailed in a series of blog posts and numerous tweets, the do-it-yourselfer to the extreme has created marzipanify, a tool open source that automatically performs several main tasks :

  • he repackage the iOS app in a format that is compatible with macOS

  • it redirects all the links of the framework, UIKit from iOS to framework UIKit macOS

  • it modifies theheader Mach binaries

  • it modifies the file Info.plist , which contains metadata of the app

  • he signs the app with the rights related to macOS (push notifications, iCloud…)

To convert our mobile application, Laurent, our iOS developer emeritus, has followed the guide of PSPDFKit. Without going into too much technical detail (they are described by the menu, by the creators of the PDF Viewer), we can note several things about the conversion process with marzipanify.

marzipanify in action

First, it is necessary that the app “aims” iOS 12 and iOS version required as a minimum. Then, and this is the largest part of the work, it is necessary to remove it from the app of various frameworks additional. The frameworks of advertising and those that add custom functionality may not be converted, for the good reason that Apple has not yet provided for this case. Similarly, it is necessary to remove all the frameworks of iOS native for which there is no equivalent on macOS (this is especially the case of the functions related to the phone and messages).

If one forgets to remove a framework that is not supported, the app “marzipanifiée” crashes at startup. It is necessary to take his chainsaw and prune until only the trunk of the app. It is necessary, moreover, that the trunk is sufficiently modern for the port is a success : if the code contains obsolete elements (class UIWebView in place of the new class WKWebView to display a web view, for example), the application will not work on Mac.

Once all this pruning is performed and that other small concerns are resolved, we obtain… that it is not possible to open in the state on macOS. It is necessary to disable two security measures (SIP and the sandboxing of applications) by typing in two lines of commands from the restore partition of the system. It is after this step that we can open iGeneration iOS on Mac.

Hello again !

The basic features of the application respond to the call. You can browse the list of articles, mark them as favorites and read/nons read, read the articles and comments, switch to night mode, enlarge the view article… It is possible to open internal links (links to other articles of the iGeneration), but not the external links.

[embedded content]

Navigate the mouse in the interface is not so strange as that. The gesture two fingers on the trackpad or mouse to scroll the content vertically works as expected. It also works for the horizontal to switch the view article to comments.

The behaviors specific to macOS are managed. Alternately, you can resize freely the window, switch to Split View or full screen, and minimize it in the Dock. The keyboard shortcuts are not of the party, however, and you can not escape a few crashes.

iGeneration in Split View on a Mac with Safari

Laurent has achieved this result in just one afternoon ! Even before that, Apple does provide documentation and official tools, this experiment confirms that Marzipan is going to dramatically ease the porting of iOS apps to the Mac. The developer Guilherme Rambo, assisted by Steven Troughton-Smith, says that the operation will be to check a box in Xcode when it will be finalized.

As advanced as it is, marzipanify don’t say any of the strategy of Apple and of its consequences. Until where will go the integration of iOS apps in macOS (the management of the Touch Bar, the menu bar and keyboard shortcuts are apparently planned for the first version) ? Marzipan will he flatten out the Mac apps to the bottom, as feared by some ?

Of the dozens of developers, if not more, are in any case in the starting blocks for this new adventure. The WWDC 2019 promises to be exciting.