UXKit and why "UIKit for macOS" is important

Guilherme Rambo
4 min readSep 10, 2016

--

If you want to listen to conversations on this topic, check out Stacktrace #1 and Stacktrace #2.

UPDATE 18/4/25: Since originally writing this article, I changed my mind quite a bit on this topic. Specifically, I don't agree that writing native apps for the Mac is so much more difficult than making apps for iOS and even considering it's a little more difficult, it doesn't justify the lack of native apps by big companies. I still think that a more shared UI framework would be a benefit for both users and developers.

UPDATE 16/9/12: I have filed a radar asking Apple to make UXKit public. You can find it on OpenRadar.

I've been writing O̶S̶X̶ macOS apps for fun since 2009/2010 and more seriously recently. I have a lot of open-source projects and some commercial projects focused on the platform, one of which I'm using right now to write this post.

When the iPhone first launched, I couldn't afford one, so I didn't pay much attention to the product and the ecosystem.

More recently, I started to work on a project which will be available on the 13th, with iOS 10. I had played around with iOS development and done some simple projects but this is my first "serious" iOS app.

What I learned from doing this project? Well, UIKit is good, AppKit sucks.

Before using UIKit more, I didn't understand why iOS developers complained so much about AppKit and why so many of them wanted "UIKit for Mac" so desperately. Now I know why.

The thing is, UIKit "just works" (most of the time at least). AppKit has so much historical garbage that it's become a pain to work with for modern macOS apps. It's still really hard to make simple things like customizing system controls and Core Animation doesn't work as well on it as it does on UIKit.

There are some really awesome iOS apps out there which would benefit a lot from a macOS counterpart, but their developers don't want to write apps for both, so they choose the one that's more popular (hint: it is not macOS). Instead, people are making crappy web-based apps, shoving them on a .app with hundreds of megabytes and calling them "macOS apps".

I didn't believe it would be possible to have a single UI framework for iOS and macOS, but I changed my mind when I saw how UIKit works on tvOS. Think about it: it's the same framework, but with a different visual language and functionality added/removed based on the needs of the platform:

  • UIKit on tvOS has facilities to work with the remote control, controlling focus and the parallax effect that is ubiquitous on the platform.
  • UIKit on iOS has touch input, gesture recognizers, toolbars and navigation bars
  • UIKit on macOS would have window controllers, contextual menus and statusbar items

UIKit for macOS already exists, and it is called UXKit

I heard about UXKit when Apple first introduced the new Photos app for macOS. I didn't pay much attention at the time because I thought it wasn't that interesting, Apple has been using custom UI frameworks for a long time now for their own apps, so I thought this was just another one of those.

I was wrong. Yesterday, I decided I would take a look at it to see what it's all about. What I found is that UXKit is really a "UIKit for Mac". You can pretty much just copy your iOS code over and replace "UI" by "UX" on the names of the classes.

The intention of the framework became even more clear when I decided to reverse-engineer it. There are lots of categories on AppKit classes called "compatibility". Most of them implement UIKit-like selectors that call native AppKit methods to do their job.

Class-dump generated header from UXKit's NSProgressIndicator+Compatibility category

But the most interesting things are the UX-prefixed classes. Most of them are implementations of UIKit controls on top of AppKit. There's UXLabel, UXCollectionView, UXNavigationController, UXViewController and much more.

To see for myself whether I was right, I decided to try and build a really simple app using UXKit. The code is available on my Github. This app lets the user search for photos on Flickr and select them to see a bigger version, really simple.

While working on the app I noticed that it felt like I was working on an iOS app (I know how it feels like, I've been doing it daily for the last 2 months straight :P).

UXKit Demo, a sample app made using Apple's UXKit framework

I think a developer who is familiar with UIKit would have no problem making macOS apps using UXKit. From what I know, the only apps that use UXKit currently are the macOS Photos app and the Pricing app (the one used at Apple Stores).

Unfortunately, it's still a private framework and there's no indication that Apple will ever make it public.

Until then, we'll have to keep working with AppKit and writing our own compatibility layers on top of it.

--

--