Skip to content

Setting Up Kiwi 2.x without CocoaPods

Schubert Anselme edited this page Jan 30, 2014 · 8 revisions

The recommended means of adding Kiwi to a project is to use the CocoaPods-based setup described in Getting Started with Kiwi 2.0. However, if you would prefer to set up Kiwi without using CocoaPods, you can follow the steps described here.

There are two ways; First: Importing Kiwi project into your Xcode workspace, which is basically what CocoaPods will do for you and second is Importing Kiwi as a framework, which is better if you prefer to keep your project/workspace simple.

Below steps assume Kiwi has been downloaded and there is an existing project with at least one unit-test target.

Adding Kiwi as a project into your Xcode workspace

  1. Add the Kiwi project to the Xcode workspace.
  2. Add the Kiwi headers directory to User Headers Search Path of the test target.
  3. Add the libKiwi.a static library to the test target.
  4. Add -ObjC to the Other Linker Flags of the test target.[1]

See Guide: Up and Running with Kiwi for details of setting up a test project and adding the Kiwi library.

Adding Kiwi binary into your Xcode project

  1. Select Project > Scheme > Kiwi-iOS from Xcode menu bar and then build it (Cmd+b). Building might take a while since it will compile i386 and arm architectures. When it finishes a finder window will show a folder containing Kiwi.framework
  2. Drag and drop Kiwi.framework to somewhere in your project.
  3. Add Kiwi.framework to Link Binary with Libraries of your test target.
  4. Add -ObjC the Other Linker Flags of the test target. [1]

For more information about setting up a unit-test target, see Apple's Xcode Unit Testing Guide.

[1]: Old compilers/linkers (prior to Xcode 4.5) might additionally need -all_load or -force_load libKiwi.a

Use Kiwi (XCTest) binary into your Xcode project

  1. Build Kiwi-XCTest using iOS Simulator
  2. Copy libKiwi-XCTest.a somewhere (ex.: ~/Desktop/Kiwi/simulator)
  3. Build Kiwi-XCTest using an iOS Device (ex.: iPhone)
  4. Copy libKiwi-XCTest.a somewhere (ex.: ~/Desktop/Kiwi/device)
  5. Copy Kiwi-XCTest (which contains the headers) somewhere (ex.: ~/Desktop/Kiwi/simulator)
  6. Move into where you copied the files from the previous steps (ex: cd ~/Desktop/Kiwi)
  7. Create a new directory where to put the universal binary (ex.: mkdir -p ~/Desktop/Kiwi/universal)
  8. Link the simulator and device binaries into the universal binary directory (ex.: lipo simulator/libKiwi-XCTest.a device/libKiwi-XCTest.a -create -output universal/libKiwi.a)
  9. Copy the headers (either from simulator or device directory) into the universal directory (ex.: cp -r simulator/Kiwi-XCTest universal/Kiwi)
  10. Create a framework container (ex.: mkdir -p Kiwi.framework && mkdir -p Kiwi.framework/Versions/A/Resources)
  11. Copy the universal binary into the framework (ex.: cp universal/libKiwi.a Kiwi.framework/Versions/A/Kiwi)
  12. Copy the headers into the framework (ex.: cp -r universal/Kiwi Kiwi.framework/Versions/A/Headers)
  13. Create a Current simlink in the framework Versions directory (ex.: ln -s A Kiwi.framework/Versions/Current)
  14. Create simlinks in the framework root for the binary, headers and resources (ex.: ln -s Versions/Current/Kiwi Kiwi.framework/Kiwi && ln -s Versions/Current/Headers Kiwi.framework/Headers && ln -s Versions/Current/Resources Kiwi.framework/Resources)
  15. Add the framework to your project (easiest way is to drag-n-drop it in the Frameworks directory in your project and select the test target. I would recommend selecting the copy items into group's folder)
  16. In your test target add -all_load in Other Linker Flags