|
5 | 5 | - [`rules_xcodeproj_generator`](#rules_xcodeproj_generator) |
6 | 6 | - [`rules_xcodeproj_indexbuild`](#rules_xcodeproj_indexbuild) |
7 | 7 | - [`rules_xcodeproj_swiftuipreviews`](#rules_xcodeproj_swiftuipreviews) |
| 8 | + - [`rules_xcodeproj_coverage`](#rules_xcodeproj_coverage) |
8 | 9 | - [Project-level configs](#project-level-configs) |
9 | 10 | - [Extra config flags](#extra-config-flags) |
10 | 11 | - [`.bazelrc` files](#bazelrc-files) |
@@ -119,6 +120,31 @@ SwiftUI Preview build. |
119 | 120 | You shouldn’t need to adjust this config. The default config applies the needed |
120 | 121 | build adjusting flags. |
121 | 122 |
|
| 123 | +### `rules_xcodeproj_coverage` |
| 124 | + |
| 125 | +The `rules_xcodeproj_coverage` config is used when building the project tests |
| 126 | +inside of Xcode when code coverage is enabled. This config sets the needed |
| 127 | +features inside apple_support and rules_swift to generate coverage data with |
| 128 | +absolute paths to sources so Xcode can map them correctly. |
| 129 | + |
| 130 | +By default, code coverage is **disabled** for test actions of schemes. You can |
| 131 | +enable code coverage in Xcode by setting `code_coverage = True` on an |
| 132 | +[`xcschemes.test_options`](/doc/bazel.md#xcschemes.test_options-code_coverage) |
| 133 | +declaration, or by enabling the "Gather coverage data" option in the scheme editor. |
| 134 | + |
| 135 | +> [!WARNING] |
| 136 | +> Enabling code coverage will cause tests to be built for coverage, which is a |
| 137 | +> distinct configuration mode from normal test builds. For building in Xcode |
| 138 | +> in particular, this results in build outputs that are inherently non-hermetic |
| 139 | +> as they contain absolute paths to source files. This will result in poor |
| 140 | +> cache hit rates for these builds. This does not impact `coverage` builds run |
| 141 | +> using the [command-line API](#command-line-api) or normal `bazel test` runs. |
| 142 | +> |
| 143 | +> It is recommended to only enable code coverage inside of Xcode when actively |
| 144 | +> using it for development, and to use tool sets like |
| 145 | +> [lcov](https://registry.bazel.build/modules/lcov) to produce coverage reports |
| 146 | +> from normal `bazel` test runs. |
| 147 | +
|
122 | 148 | ## Project-level configs |
123 | 149 |
|
124 | 150 | Each `xcodeproj` can specify a set of configs which inherit from the |
|
0 commit comments