These scripts provide a simple way to generate HTML reports of the code coverage
of your Xcode project.
For a detailed blog post, see http://qualitycoding.org/xcode-code-coverage/
For additional steps needed to get code coverage in iOS 7, see http://qualitycoding.org/ios-7-code-coverage/
Fixes error because lcov tries to call -v on the llvm-wrapper, i added a wrapper for the wrapper ;-)
- Fork this repository; you're probably going to want to make your own modifications.
- Place the XcodeCoverage folder in the same folder as your Xcode project.
- Dowload lcov-1.10. Place the lcov-1.10 folder inside the XcodeCoverage folder.
- Get Xcode's coverage instrumentation by going to Xcode Preferences, into Downloads, and installing Command Line Tools.
- In your Xcode project, enable these two build settings at the project level for your Debug configuration only:
- Instrument Program Flow
- Generate Test Coverage Files
- In your main target, add a Run Script build phase to execute
XcodeCoverage/exportenv.sh
A few people have been tripped up by the last step: Make sure you add the script to your main target (your app or library), not your test target.
- Run your unit tests
- In Terminal, execute
getcov
in your project's XcodeCoverage folder.
If you make changes to your test code without changing the production code and
want a clean slate, use the cleancov
script.
If you make changes to your production code, you should clear out all build artifacts before measuring code coverage again. "Clean Build Folder" by holding down the Option key in Xcode's "Product" menu.
There are two places you may want to modify:
- In envcov.sh,
LCOV_INFO
determines the name shown in the report. - In getcov, edit
exclude_data()
to specify which files to exclude, for example, third-party libraries.