Skip to content

Commit d9f68f7

Browse files
committed
Add xcconfig
1 parent 162da31 commit d9f68f7

File tree

2 files changed

+27
-14
lines changed

2 files changed

+27
-14
lines changed

README.md

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,12 @@
33
These scripts provide a simple way to generate HTML reports of the code coverage of your Xcode project.
44

55

6-
Xcode Project Setup
7-
===================
8-
9-
Before you get started, there are a couple of steps you will need to take to prepare your project:
10-
11-
1. Depending on your version of Xcode, you may need to get Xcode's coverage instrumentation by going to Xcode > Preferences, into Downloads, and installing Command Line Tools. If you do not see this as an option in the Downloads section, the tools should already be installed.
12-
2. In your Xcode project, enable these two build settings at the project level for your Debug configuration only:
13-
* Instrument Program Flow
14-
* Generate Test Coverage Files
15-
16-
176
Installation: Standard
187
======================
198

20-
1. Fork this repository; you're probably going to want to make your own modifications.
9+
Use the standard installation if you want to customize XcodeCoverage to exclude certain files and directories, such as third-party libraries. Otherwise, the CocoaPods installation described below may be more convenient.
10+
11+
1. Fork this repository.
2112
2. Place the XcodeCoverage folder in the same folder as your Xcode project.
2213
3. In your main target, add a Run Script build phase to execute `XcodeCoverage/exportenv.sh`
2314

@@ -44,6 +35,23 @@ The steps to install via CocoaPods:
4435
Again, make sure you add the script to your main target (your app or library), not your test target.
4536

4637

38+
Xcode Project Setup
39+
===================
40+
41+
XcodeCoverage comes with an xcconfig file with the build settings required to instrument your code for coverage analysis.
42+
43+
If you already use an xcconfig, include it in the configuration you want to instrument:
44+
* Standard installation: `#include "XcodeCoverage/XcodeCoverage.xcconfig"`
45+
* CocoaPods installation: `#include "Pods/XcodeCoverage/XcodeCoverage.xcconfig"`
46+
47+
If you don't already use an xcconfig, drag XcodeCoverage.xcconfig into your project. Where it prompts "Add to targets," deselect all targets. (Otherwise, it will be included in the bundle.) Then click on your project in Xcode's Navigator pane, and select the Info tab. For the configuration you want to instrument, select XcodeCoverage.
48+
49+
If you'd rather specify the build settings by hand, enable these two settings at the project level:
50+
* Instrument Program Flow
51+
* Generate Test Coverage Files
52+
53+
Make sure not to instrument your AppStore release.
54+
4755
Execution
4856
=========
4957

@@ -68,13 +76,13 @@ If you make changes to your production code, you should clear out all build arti
6876
* Edit Xcode scheme -> Test -> Post-actions
6977
* Set "Shell" to: `/bin/bash`
7078
* Set "Provide build settings from" to your main target
71-
* Set script to: `source ${SRCROOT}/XcodeCoverage/run_code_coverage_post.sh` for standard installation. For CocoaPod installation, use `source ${SRCROOT}/Pods/XcodeCoverage/run_code_coverage_post.sh`
79+
* Set script to `source XcodeCoverage/run_code_coverage_post.sh` for standard installation. For CocoaPods installation, use `source Pods/XcodeCoverage/run_code_coverage_post.sh`
7280

7381

7482
Modification
7583
============
7684

77-
If you are using the standard installation, you may wish to modify `exclude_data()` in `getcov` to specify which files to exclude, for example, third-party libraries.
85+
If you are using the standard installation, you can modify `exclude_data()` in `getcov` to specify which files to exclude, such as third-party libraries.
7886

7987

8088
Credits

XCodeCoverage.xcconfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// XcodeCoverage by Jon Reid, http://qualitycoding.org/about/
2+
// Source: https://github.com/jonreid/XcodeCoverage
3+
4+
GCC_GENERATE_TEST_COVERAGE_FILES = YES
5+
GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = YES

0 commit comments

Comments
 (0)