Skip to content

Up and Running with CocoaPods

MaxGabriel edited this page Feb 25, 2013 · 13 revisions

Installing Kiwi with Cocoapods

1. Installing Cocoapods

2a. Adding Kiwi to an Existing Project without a Unit Test Target

  • In Xcode, add a Unit Test target to the application project (File > New > Target > Cocoa Touch Unit Testing Bundle). Name it KiwiUnitTest

  • Close your Xcode project and use the terminal to navigate to your project's directory.

  • If you don't have one already, make a new file called Podfile with no extension: touch Podfile

  • Add the Kiwi reference to the Podfile:

    platform :ios
    target :KiwiUnitTest, :exclusive => true do
        pod 'Kiwi'
    end
  • Run pod install from the command line.

  • Open the newly created Xcode Workspace file.

  • Edit the scheme for your primary target (e.g. MyProject) (Product > Scheme > Edit Scheme). Choose Test in the sidebar, then click the + button to add the KiwiUnitTest target. At this point, ⌘-U should result in Xcode executing the default (failing) test.

  • Under the KiwiUnitTest target, set the Bundle Loader Build Setting to the main target's executable, e.g. $(BUILT_PRODUCTS_DIR)/MyProject.app/MyProject

  • Under the KiwiUnitTest target, set the Test Host Build Setting to $(BUNDLE_LOADER)

  • Write some test classes, adding them to the KiwiUnitTest target.

2b. Adding Kiwi to an Existing Project with a Unit Test Target

  • Close your Xcode Project and use the terminal to navigate to your project's directory.
  • If you don't have one already, make a new file called Podfile with no extension: touch Podfile
  • Add the Kiwi reference to the Podfile (Replace KiwiUnitTest with your Unit Test Target's name).
    platform :ios
    target :KiwiUnitTest, :exclusive => true do
        pod 'Kiwi'
    end
  • Run pod install from the command line.
  • Open the Xcode Workspace file and run your tests with ⌘-U

2c. Adding Kiwi to a New Project

  • In Xcode, create a new Project (⌘-Shift-N).
  • Check the Include Unit Tests option.
  • Close your Xcode Project and use the terminal to navigate to your project's directory.
  • Make a new file called Podfile with no extension: touch Podfile
  • Add the Kiwi reference to the Podfile (Replace KiwiUnitTest with your Unit Test Target's name).
    platform :ios
    target :KiwiUnitTest, :exclusive => true do
        pod 'Kiwi'
    end
  • Run pod install from the command line.
  • Open the newly created Xcode Workspace file and run your tests with ⌘-U