Kiwi as a static framework or Universal Library
A problem commonly encountered when using open-source iOS frameworks is the lack of a fully-functional framework facility in xCode. Part of the issue is that Apple does not allow dynamic linking on iOS devices, the other is that there are two different architectures that need to be supported by libraries targeting both armv6 (up to iPhone 3G) and armv7 devices (iPhone 3GS and later). On top of that, we also need a binary that will run on the simulator (x86).
The easiest solution to the library problem in XCode is using project dependencies to build libraries in the configuration you need them. When taking a source dependency is not desirable, you are pretty much left to your own if the OSS project doesn’t provide binaries.
Fortunately enough, it’s not too difficult to build your own universal frameworks. Below are the steps I use for building a version of Kiwi:
- Grab the Universal Framework XCode templates from https://github.com/kstenerud/iOS-Universal-Framework
- Install the Fake framework flavor (although the Real framework flavor should work as well)
- Create a new xCode project with the Fake framework template
- Add all source files of Kiwi (make sure to check the Copy to destination group folder box)
- Select the Kiwi static library target, project editor, build phases, Copy Headers, select all headers in the Project Group, right click and select move to Public
- Select the Kiwi static library target, project editor, build phases, link binary with libraries and add SenTestingKit.framework
- Go to the Project Navigator (Cmd-1) and select Products Kiwi.framework. Right-Click and select “Show in Finder”
- You should see two folders: Kiwi.framework and Kiwi.embeddedframework – Kiwi.framework is the one we need
- Copy the Kiwi.framework folder into your lib folder
- Open the project you want to use Kiwi.framework in and select your target, project editor, build phases, link binary with libraries, click + and add Kiwi.framework from your lib folder
That’s it. Takes less than two minutes once you know the trick.