Skip to content

Up and Running with CocoaPods

MaxGabriel edited this page Feb 4, 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 Xcode 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 and click the + button and add the KiwiUnitTest target (so you can do ⌘-U).

  • Add the path to the Main Target's executable to the Bundle Loader build setting in the KiwiUnitTest Target : e.g. $(BUILT_PRODUCTS_DIR)/MyProject.app/MyProject

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

  • Run the Tests (⌘-U or Product > Test).

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

  • Close Xcode 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 Xcode 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