MAIKit: A Framework for Sharing Code Between iOS and OS X
In the year since Apple introduced Continuity to iOS 8 and OS X Yosemite, Mac app development has become more attractive to iOS developers. Although Apple’s new Photos app ships with a private framework named UXKit, which implements a subset of UIKit on OS X, Apple has yet to provide developers a way to write cross-platform code. Third-party frameworks like Chameleon exist, but because UIKit lacks APIs for some features of OS X, apps built with UIKit feel limited on OS X. However, since UIKit and Appkit are very similar, many developers alias UIKit and Appkit classes and use methods common to both frameworks.
For the past few months, I’ve been experimenting with automating this technique by parsing the UIKit and AppKit headers to extract the interfaces common to both, and the result is MAIKit. I thought that even if this wasn’t an ideal way to develop cross-platform code, if this is something a lot of developers are doing, we could all benefit by automating the process.
I’m releasing MAIKit now because it has already helped me write cross-platform code faster, but there is still much work left to do. The ruby script used to generate the framework is a showcase of bad code. It developed organically as I was figuring out how feasible this project was, and needs to be completely redone. I also plan to add category methods to fill in bits of functionality that are not similar across UIKit and AppKit (e.g. setting button titles).
If you think MAIKit is a good fit for your project, please check out the GitHub repo, where you can also find documentation and sample code. And if you feel like it, bug reports, feature requests, and pull requests are always welcome.