Fork me on GitHub

Code Coverage for iOS and OSX

Free for both commercial and open-source projects!


Generating a code coverage report for iOS and OSX projects requires a mish-mash of tools and steps. Here we've glued them all together into something that (hopefully) just works. All it took was a little Java, some Perl, a few shell scripts, a couple of Ruby Gems . . . and now you can:

  • Generate a report with minimal steps.
  • Output to the terminal as well as produce a detailed report in build-server friendly HTML format.
  • Use the optional coverage checker, for example in CI builds to check minimum test coverage - failing the build if coverage falls below the required amount.
  • Use it for free for both commercial and open-source projects!

Swift? Sorry, no dice

As yet there's no way to generate code coverage reports for Swift. If, like us, you'd like to see this implemented by Apple, please vote on this issue.


The script itself can be run remotely, but we'll first need to install dependencies . . .

With HomeBrew

$ brew install groovy
$ brew install lcov

With MacPorts

$ sudo port install groovy
$ sudo port install lcov

NB: Xcode 7.x requires lcov 1.12, or no coverage will be produced. If you haven't updated your Brew or MacPorts sources for a while, please do so or you might end up with lcov 1.10.


Set your main App target to produce test coverage output (debug mode only).

Set your main App target to instrument program flow (debug mode only).



Run your tests from Xcode or AppCode, and then produce a coverage report with:

groovy -source-dir MyProject/Classes


Create a build script, as follows:

# First Run Tests
xcodebuild test -workspace MyProject.xcworkspace/ \
-scheme 'MyProject' \
-configuration Debug \
-destination 'platform=iOS Simulator,name=iPhone 5s,OS=8.1' | xcpretty -c

#Above we're piping output through xcpretty, which is not required
#but very nice! (gem install xcpretty)

# Now Produce Test Coverage Report
groovy -source-dir MyProject/Classes \
-required-coverage 85

#We set required coverage to 85% - build fails if coverage
#falls below this value.

. . . and run it with

$ sh


Contact us

Brought to you by

This project is sponsored and lead by We are a small team of passionate, top-notch developers. For our clients we develop stunning rich-media and mobile applications. In the community we lead a number of open source projects. These include the popular Typhoon Framework and XCodeEditor - proudly powering your favorite Alcatraz plugins.

And the awesomeness of. . .

The script just moves a bunch of files into the right place and runs some commands on them, hopefully saving you the time of having to read the detailed documentation and run manual steps. The real heavy-lifting is being done by the awesomeness of clang and lcov.

Licensed under the Apache License, Version 2.0, January 2004,

Visit our website:
Email us:
Call by phone:+63 939 930 2676