Installing in iOS (Xcode 5)

To use GHUnit in your project, you’ll need to create and configure a test target.

Create Test Target

  • You’ll want to create a separate Test target. Select the project file for your app in the Project Navigator. From there, select the “Add Target…” button in the right window.

Add Target

  • Select iOS, Application, Empty Application. Select Next.

Select Application

  • Name it Tests or something similar. Select Finish.

Name it

Configure the Test Target

  • Select the created Test target and select the tab “Build Phases”. Open the “Link Binary With Libraries” option and click on the “+” button.

Add QuartzCore

  • Select QuartzCore.framework and click “Add”.

  • Download GHUnitIOS.framework and unzip it in your Test Target directory (a subdirectory of your project directory).

  • Select the created Test target and select the tab “Build Phases”. Open the “Link Binary With Libraries” option and click on the “+” button.

Add Framework

  • Click “Add Other…”.

Add Framework Dialog

  • Select the GHUnitIOS.framework from your Test Target directory.

  • We want to enable use of Objective-C categories, which isn’t enabled for static libraries by default. In the Tests target, Build Settings, under Other Linker Flags, add -ObjC.

Other Linker Flags

  • Select and delete the files from the existing Tests folder. Leave the Supporting Files folder. GHUnit will provide the application delegate below.

Remove Test Files

  • In Tests folder, in Supporting Files, main.m, replace the last argument of UIApplicationMain with @"GHUnitIOSAppDelegate". Remove the #import "AppDelegate.h" if present.

Main Method

  • Select the Tests target, iPhone Simulator configuration:

Select Target

  • Hit Run, and you’ll hopefully see the test application running (but without any tests).

Run It

Now you can create and run tests!