UXKit is a framework used in Photos.app that attempt to port the UIKit APIs to OSX, as a replacement for AppKit. Will this framework allow us to write iOS and OSX Applications without duplicating code?
As an iOS Developer that had to deal with the gap between UIKit and AppKit during the development of MiniPlayer for Mac I can’t hide my excitment about UXKit. AppKit is not that bad, is just not modern, easy and fast to write as UIKit. I never use Interface Builder for iOS but I had to use it in MiniPlayer because I didn’t want to deal too much with AppKit.
I started from this project that contains a modified version of UXKit that works on OSX 10.10.2 and tried to create a simple cross-platform sample Application. I deleted the sample and created one that could be cross-platform.
The first step was to create a UIXCompatibility header; it defines
TARGET_UIKIT based on the platform, includes the right framework and for
TARGET_UXKIT uses some
@compatibility_alias that allows me to use the same classes for both platforms.
@compatibility_alias were needed even from AppKit classes like
NSColor in order to not write
#ifdefs everywhere; all those bridges should be covered by UXKit if it will ever become public.
This is the more or less Out-of-the-Box result of using my old and beloved MPSkewed with UXKit:
UXKit is still far from completely compatible with
UIKit but I really hope this project will be refined and available for everyone in future!