Skip to content

Instantly share code, notes, and snippets.

@wooster
Last active December 10, 2015 06:18
Show Gist options
  • Save wooster/4393734 to your computer and use it in GitHub Desktop.
Save wooster/4393734 to your computer and use it in GitHub Desktop.
Code coverage in Xcode projects

In Xcode 4.5 with LLVM, to enable code coverage on a project:

  • Set "Instrument Program Flow" and "Generate Test Coverage Files" to Yes in the Build Settings.
  • You'll want to have the program properly exit in order to generate the files. A simple way is:
- (void)applicationDidEnterBackground:(UIApplication *)application {
    exit(0);
}

It's best to create this in a new build configuration. Run your app in the simulator and hit the Home button to have the right files generated.

Afterwards, the files will be in something like "build/$target/$project.build/Debug-iphonesimulator/$target.build/Objects-normal/i386/".

You can open this directory in Cover Story, but if your project has a lot of files you may need to apply the patch in issue 39.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment