Skip to content

Commit bcbfc88

Browse files
committed
docs, support renamed features in other PRs
1 parent 4de34e3 commit bcbfc88

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

docs/usage.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- [`rules_xcodeproj_generator`](#rules_xcodeproj_generator)
66
- [`rules_xcodeproj_indexbuild`](#rules_xcodeproj_indexbuild)
77
- [`rules_xcodeproj_swiftuipreviews`](#rules_xcodeproj_swiftuipreviews)
8+
- [`rules_xcodeproj_coverage`](#rules_xcodeproj_coverage)
89
- [Project-level configs](#project-level-configs)
910
- [Extra config flags](#extra-config-flags)
1011
- [`.bazelrc` files](#bazelrc-files)
@@ -119,6 +120,31 @@ SwiftUI Preview build.
119120
You shouldn’t need to adjust this config. The default config applies the needed
120121
build adjusting flags.
121122

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+
122148
## Project-level configs
123149

124150
Each `xcodeproj` can specify a set of configs which inherit from the

xcodeproj/internal/templates/xcodeproj.bazelrc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ common:rules_xcodeproj_coverage --config=rules_xcodeproj
9191

9292
# Enable features that allow for building for instrumentation.
9393
#
94-
# Of particular note are the (swift./)coverage_prefix_map_canonical_non_hermetic
94+
# Of particular note are the (swift./)_coverage_prefix_map_absolute_sources_non_hermetic
9595
# features, which remap the execroot during the build as the absolute, canonical path
9696
# to the source root.
9797
#
@@ -100,11 +100,11 @@ common:rules_xcodeproj_coverage --config=rules_xcodeproj
100100
# coverage).
101101
common:rules_xcodeproj_coverage --features=coverage
102102
common:rules_xcodeproj_coverage --features=llvm_coverage_map_format
103-
common:rules_xcodeproj_coverage --features=coverage_prefix_map_canonical_non_hermetic
103+
common:rules_xcodeproj_coverage --features=_coverage_prefix_map_absolute_sources_non_hermetic
104104
common:rules_xcodeproj_coverage --features=swift.coverage
105-
common:rules_xcodeproj_coverage --features=swift.coverage_prefix_map_canonical_non_hermetic
105+
common:rules_xcodeproj_coverage --features=swift._coverage_prefix_map_absolute_sources_non_hermetic
106106

107-
# Disable features that interfere with (swift./)coverage_prefix_map_canonical_non_hermetic
107+
# Disable features that interfere with (swift./)_coverage_prefix_map_absolute_sources_non_hermetic
108108
common:rules_xcodeproj_coverage --features=-coverage_prefix_map
109109
common:rules_xcodeproj_coverage --features=-file_prefix_map
110110
common:rules_xcodeproj_coverage --features=-swift.coverage_prefix_map

0 commit comments

Comments
 (0)