### `--config=rules_xcodeproj`
#
# Used directly when doing a normal build, but it is also the base config of all
# the `rules_xcodeproj_*` configs. Adjust this config if you want something to
# apply to all builds (which should be most settings).

common:rules_xcodeproj --verbose_failures

# Increase the default file digest cache size to 500k entries, as 50k (the
# default) is too small for large projects.
common:rules_xcodeproj --cache_computed_file_digests=500000

# We default to `dbg` since debugging is broken otherwise
common:rules_xcodeproj --compilation_mode=dbg

# Xcode builds shouldn't mess with the workspace's symlinks
common:rules_xcodeproj --experimental_convenience_symlinks=ignore

# Projects with large C/C++ target command-lines can fail to generate due
# without using params files. While the targets themselves might use params
# files, currently `Action.args` won't unless
# `--experimental_use_cpp_compile_action_args_params_file` is set.
# https://github.com/bazelbuild/bazel/issues/20746 would allow us to remove the
# need for this flag.
common:rules_xcodeproj --experimental_use_cpp_compile_action_args_params_file

# Not using `--define=apple.experimental.tree_artifact_outputs=1` is slow (we
# have to unzip an archive on each build). If this doesn't work for your
# project, you can set `--define=apple.experimental.tree_artifact_outputs=0`
# on `common:rules_xcodeproj` in your `.bazelrc` or `xcodeproj.bazelrc` file.
common:rules_xcodeproj --define=apple.experimental.tree_artifact_outputs=1

# Fix Test Issue navigation
common:rules_xcodeproj --features=apple.swizzle_absolute_xcttestsourcelocation

# `oso_prefix_is_pwd` removes absolute paths in debug info, which increases
# cache hit rates. We "undo" this in `bazel.lldbinit`, so debugging still works.
common:rules_xcodeproj --features=oso_prefix_is_pwd

# `relative_ast_path` uses relative paths when passing `--add_ast_path` to the
# linker, which increases cache hit rates. We "undo" this in `bazel.lldbinit`,
# so debugging still works.
common:rules_xcodeproj --features=relative_ast_path

# `swift.cacheable_swiftmodules` passes `-no-serialize-debugging-options` to
# `swiftc`, which fixes lldb crashes and increases cache hit rates. We "undo"
# this in `swift_debug_settings.py`, so debugging still works.
common:rules_xcodeproj --features=swift.cacheable_swiftmodules

# `swift.index-while-building` passes `-index-store-path` to `swiftc`, which
# generates index store data. We enable this globally, because we import indexes
# in Index Build as well. And even if we didn't, we would still want it enabled
# to get cache hits between normal and Index Build builds.
common:rules_xcodeproj --features=swift.index_while_building
common:rules_xcodeproj --features=swift.use_global_index_store

# Removes potentially large unneeded event from the BEP
common:rules_xcodeproj --nolegacy_important_outputs

# `--show_result=0` prevents showing the spec.json and intermediate `.xcodeproj`
# in the logs when generating, and all of the many outputs when building
common:rules_xcodeproj --show_result=0

# Disable sandboxing. Sandboxing on macOS is still very slow.
common:rules_xcodeproj --noworker_sandboxing
common:rules_xcodeproj --spawn_strategy=remote,worker,local

# Needed to download aspect output groups
build:rules_xcodeproj --remote_download_outputs=toplevel

### `--config=rules_xcodeproj_generator`
#
# Used when generating a project.

common:rules_xcodeproj_generator --config=rules_xcodeproj

### `--config=rules_xcodeproj_indexbuild`
#
# Used when doing an Index Build.

common:rules_xcodeproj_indexbuild --config=rules_xcodeproj

# Disable BES for Index Builds, as it runs a lot, and isn't user invoked
common:rules_xcodeproj_indexbuild --bes_backend= --bes_results_url=

### `--config=rules_xcodeproj_coverage`
#
# Used when doing building for code coverage.

common:rules_xcodeproj_coverage --config=rules_xcodeproj

# Enable features that allow for building for instrumentation.
#
# Of particular note are the (swift./)_coverage_prefix_map_absolute_sources_non_hermetic
# features, which remap the execroot during the build as the absolute, canonical path
# to the source root.
#
# This approach breaks remote caching when building for testing and codeCoverageEnabled
# is set to YES, but does not affect other builds (for running, or for testing without
# coverage).
common:rules_xcodeproj_coverage --features=coverage
common:rules_xcodeproj_coverage --features=llvm_coverage_map_format
common:rules_xcodeproj_coverage --features=_coverage_prefix_map_absolute_sources_non_hermetic
common:rules_xcodeproj_coverage --features=swift.coverage
common:rules_xcodeproj_coverage --features=swift._coverage_prefix_map_absolute_sources_non_hermetic

# Disable features that interfere with (swift./)_coverage_prefix_map_absolute_sources_non_hermetic
common:rules_xcodeproj_coverage --features=-coverage_prefix_map
common:rules_xcodeproj_coverage --features=-file_prefix_map
common:rules_xcodeproj_coverage --features=-swift.coverage_prefix_map
common:rules_xcodeproj_coverage --features=-swift.file_prefix_map

### `--config=rules_xcodeproj_swiftuipreviews`
#
# Used when doing a Xcode Previews build.

common:rules_xcodeproj_swiftuipreviews --config=rules_xcodeproj

# Allow frameworks to find framework dependencies when running a preview
# See `$PROJECT_FILE_PATH/rules_xcodeproj/bazel/copy_outputs.sh` for more info
common:rules_xcodeproj_swiftuipreviews --linkopt="-Wl,-rpath,@loader_path/SwiftUIPreviewsFrameworks"

# `swiftc` flags needed for SwiftUI Previews
common:rules_xcodeproj_swiftuipreviews --@@rules_swift+//swift:copt=-Xfrontend --@@rules_swift+//swift:copt=-enable-implicit-dynamic
common:rules_xcodeproj_swiftuipreviews --@@rules_swift+//swift:copt=-Xfrontend --@@rules_swift+//swift:copt=-enable-private-imports
common:rules_xcodeproj_swiftuipreviews --@@rules_swift+//swift:copt=-Xfrontend --@@rules_swift+//swift:copt=-enable-dynamic-replacement-chaining

### `--config=_rules_xcodeproj_build`
#
# Private implementation detail. Don't adjust this config, adjust
# `rules_xcodeproj` instead. This config exists solely to allow project-level
# configs to work correctly.

common:_rules_xcodeproj_build --config=rules_xcodeproj

### Project specific configs

# Import `xcodeproj.bazelrc` if it exists
try-import %workspace%/xcodeproj.bazelrc
