TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/MobileNativeFoundation/rules_xcodeproj/llms.txt
Use this file to discover all available pages before exploring further.
xcschemes module provides a set of functions for defining custom Xcode schemes (.xcscheme files). Pass a list of xcschemes.scheme() values to the xcschemes attribute of xcodeproj to create schemes with precise control over build, run, test, and profile actions, including launch targets, arguments, environment variables, diagnostics, and pre/post scripts. Load the module with:
Full example
The following example shows a complete custom scheme that launches an app, runs unit tests, and mirrors run settings for profiling:xcschemes.scheme
xcodeproj.xcschemes.
The name of the scheme. This becomes the
.xcscheme filename visible in Xcode’s scheme picker.A value returned by
xcschemes.run.If None, xcschemes.run() will be used, meaning no targets are built for the Run action (except targets declared in the build_targets of profile and test).A value returned by
xcschemes.test.If None, xcschemes.test() will be used, meaning no targets are built for the Test action.A value returned by
xcschemes.profile, or the string "same_as_run".If "same_as_run" (the default), the same targets built for the Run action are also built for the Profile action. If None, xcschemes.profile() is used, meaning no targets are built for Profile.xcschemes.run
Command-line arguments to use when running the launch target.If
"inherit" (the default), arguments are supplied by the launch target’s own args attribute (e.g. cc_binary.args). Pass None or [] to set no arguments. Each element can be a plain string (transformed to xcschemes.arg(element)) or a value from xcschemes.arg.Additional targets to build when running. Each element can be a label string (transformed to
xcschemes.top_level_build_target(label)), a value from xcschemes.top_level_build_target, or a value from xcschemes.top_level_anchor_target. Defaults to [].Diagnostics settings to enable when running. Can be
None (no diagnostics) or a value returned by xcschemes.diagnostics.Environment variables to set when running. If
"inherit" (the default), variables are supplied by the launch target. Pass None or {} to set no variables. Dictionary values can be plain strings (transformed to xcschemes.env_value(value)) or values from xcschemes.env_value.Whether to include the rules_xcodeproj default Bazel environment variables (
BUILD_WORKING_DIRECTORY, BUILD_WORKSPACE_DIRECTORY, etc.) in addition to those set by env. Does not apply to xcschemes.launch_path targets. Defaults to True.The target to launch when running. Can be
None, a label string (transformed to xcschemes.launch_target(label)), a value from xcschemes.launch_target, or a value from xcschemes.launch_path. Defaults to None (Executable set to None in Xcode).Whether build post-actions should run even when the scheme’s
BuildAction fails. Defaults to False.A label string referring to a single StoreKit configuration file for use with StoreKit Testing. Defaults to
None.The Xcode configuration name to use when building targets in this Run action. If not set,
xcodeproj.default_xcode_configuration is used.xcschemes.test
Command-line arguments to use when testing. If
"inherit" (the default), arguments are supplied by the test targets’ own args attribute — provided every test target has the same arguments. Pass None or [] to set no arguments. Strings are transformed to xcschemes.arg(element).Additional targets to build when testing. Each element can be a label string, a value from
xcschemes.top_level_build_target, or a value from xcschemes.top_level_anchor_target. Defaults to [].Diagnostics to enable when testing. Can be
None or a value from xcschemes.diagnostics.Environment variables to use when testing. If
"inherit" (the default), variables are supplied by the test targets — provided all targets share the same environment. Pass None or {} to set no variables. Strings are transformed to xcschemes.env_value(value).Whether to include the rules_xcodeproj default Bazel environment variables in addition to those set by
env. Defaults to True.Additional test options such as code coverage, app language, or app region. Can be
None or a value from xcschemes.test_options.The test targets to build and run when testing. Each element can be a label string (transformed to
xcschemes.test_target(label)) or a value from xcschemes.test_target. Defaults to [].Whether the “Use the Run action’s arguments and environment variables” checkbox is checked. If
None (the default), True is used when both args and env are "inherit", otherwise False. Setting True is ignored if run.launch_target is not set to a target.The Xcode configuration name to use when building targets in this Test action. Defaults to
xcodeproj.default_xcode_configuration.xcschemes.profile
Command-line arguments to use when profiling. If
"inherit" (the default), arguments are supplied by the launch target. Pass None or [] for no arguments. Strings are transformed to xcschemes.arg(element).Additional targets to build when profiling. Each element can be a label string, a value from
xcschemes.top_level_build_target, or a value from xcschemes.top_level_anchor_target. Defaults to [].Environment variables to use when profiling. If
"inherit" (the default), variables are supplied by the launch target. Pass None or {} for no variables. Strings are transformed to xcschemes.env_value(value).Whether to include the rules_xcodeproj default Bazel environment variables in addition to those set by
env. Does not apply to xcschemes.launch_path targets. Defaults to True.The target to launch when profiling. Can be
None, a label string, a value from xcschemes.launch_target, or a value from xcschemes.launch_path. Defaults to None.Whether the “Use the Run action’s arguments and environment variables” checkbox is checked. If
None, True is used when both args and env are "inherit". Setting True is ignored if run.launch_target is not set to a target.The Xcode configuration name to use when building targets in this Profile action. Defaults to
xcodeproj.default_xcode_configuration.In most cases you can simply set
profile = "same_as_run" in xcschemes.scheme instead of constructing a full xcschemes.profile(...) value. Use xcschemes.profile only when you need custom arguments, environment variables, or a different launch target than the Run action.xcschemes.launch_target
The label string of the target to launch.
The label string of an extension host for the launch target. Required when
label is an app extension; must be set to the label of a target that bundles the extension. Otherwise must be None.Additional library targets to build when running. Must be transitive dependencies of the launch target. Each element can be a label string (transformed to
xcschemes.library_target(label)) or a value from xcschemes.library_target. Defaults to [].Post-actions to run when building or running this launch target. Elements must be values returned by
xcschemes.pre_post_actions. Defaults to [].Pre-actions to run when building or running this launch target. Elements must be values returned by
xcschemes.pre_post_actions. Defaults to [].The target environment (
"simulator" or "device") to use when resolving the label. Defaults to "simulator" if available, otherwise "device".The working directory to use when running. If not set, Xcode’s default (
DerivedData) is used.xcschemes.test_target
The label string of the test target.
Whether this test target’s checkbox is checked in the scheme. When unchecked, Xcode skips this target during testing. Defaults to
True.Additional library targets to build when testing this target. Must be transitive dependencies of the test target and must not be top-level targets (use
build_targets on xcschemes.test for those). Each element can be a label string or a value from xcschemes.library_target. Defaults to [].Post-actions to run when building or running this test target. Elements must be values from
xcschemes.pre_post_actions. Defaults to [].Pre-actions to run when building or running this test target. Elements must be values from
xcschemes.pre_post_actions. Defaults to [].The target environment (
"simulator" or "device") to use when resolving the label. Defaults to "simulator" if available, otherwise "device".xcschemes.top_level_build_target
The label string of the top-level target. Must be a top-level target (not a library target).
The label string of an extension host if
label is an app extension. Otherwise must be None.Additional library targets to build that are transitive dependencies of this top-level target. Each element can be a label string or a value from
xcschemes.library_target. Defaults to [].Post-actions to run when building or running the action this target belongs to. Elements must be values from
xcschemes.pre_post_actions. Defaults to [].Pre-actions to run when building or running the action this target belongs to. Elements must be values from
xcschemes.pre_post_actions. Defaults to [].The target environment (
"simulator" or "device") to use when resolving the label. Defaults to "simulator" if available, otherwise "device".xcschemes.top_level_anchor_target
The label string of the top-level target used as the anchor. Must be a top-level target (not a library target).
The label string of an extension host if
label is an app extension. Otherwise must be None.The library targets to build. Must be transitive dependencies of the anchor target and must not be top-level targets. Each element can be a label string or a value from
xcschemes.library_target. This list must be non-empty.The target environment (
"simulator" or "device") to use when resolving the label. Defaults to "simulator" if available, otherwise "device".xcschemes.library_target
swift_library or objc_library.
The label string of the library target. Must not be a top-level target.
Post-actions to run when building or running the action this target belongs to. Elements must be values from
xcschemes.pre_post_actions. Defaults to [].Pre-actions to run when building or running the action this target belongs to. Elements must be values from
xcschemes.pre_post_actions. Defaults to [].xcschemes.arg
The command-line argument string. Arguments containing quotes, spaces, or newlines are escaped automatically. Do not wrap arguments in extra quotes — any quotes you include will be treated as part of the argument value.
Whether the checkbox next to this argument is checked in Xcode. Unchecked arguments are not passed when running. Defaults to
True.Whether
value is treated as a single literal string. If True (the default), spaces in value are escaped so the entire value is passed as one argument. If False, spaces are not escaped, which lets you group multiple arguments under a single Xcode checkbox.xcschemes.env_value
env dictionary.
The environment variable value. Values containing quotes, spaces, or newlines are escaped automatically.
Whether the checkbox next to this environment variable is checked in Xcode. Unchecked variables are not passed when running. Defaults to
True.xcschemes.pre_post_actions.build_script
The display name of the action in Xcode. Defaults to
"Run Script".The shell script to run. The script runs in Bazel’s execution root, so you typically want to
cd "$SRCROOT" at the start.The relative execution order within the section.
None places the action at the end in a deterministic order. Smaller integers run before larger ones. The rules_xcodeproj built-in actions use orders 0, -100, -200, etc. Defaults to None.xcschemes.pre_post_actions.launch_script
The display name of the action in Xcode. Defaults to
"Run Script".The shell script to run. The script runs in Bazel’s execution root.
The relative execution order within the section.
None places the action at the end. Smaller integers run before larger ones. Defaults to None.xcschemes.autogeneration_config
scheme_autogeneration_config attribute of xcodeproj. This lets you customize the pre/post actions and options applied to all auto-generated schemes, without having to define each scheme manually.
Options for the build and run actions of auto-generated schemes. Must be a value from
xcschemes.autogeneration.run(...). Supports pre_actions, post_actions, and run_build_post_actions_on_failure. Defaults to None.Options for the test action of auto-generated schemes. Must be a value from
xcschemes.autogeneration.test(...). Supports options, pre_actions, and post_actions. Defaults to None.Options for the profile action of auto-generated schemes. Must be a value from
xcschemes.autogeneration.profile(...). Supports pre_actions and post_actions. Defaults to None.A list of regex pattern strings. Any auto-generated scheme whose name matches one of these patterns will be skipped. Defaults to
None.xcschemes.diagnostics
diagnostics parameter of xcschemes.run or xcschemes.test.
Whether to enable Address Sanitizer (ASan). Cannot be
True at the same time as thread_sanitizer. Defaults to False.Whether to enable Thread Sanitizer (TSan). Cannot be
True at the same time as address_sanitizer. Defaults to False.Whether to enable Undefined Behavior Sanitizer (UBSan). Defaults to
False.Whether to enable the Main Thread Checker. Defaults to
True.Whether to enable the Thread Performance Checker. Defaults to
True.xcschemes.test_options
test_options parameter of xcschemes.test or xcschemes.autogeneration.test.
Whether to enable code coverage collection during tests. Defaults to
False.Out-of-the-box inline code coverage UI in Xcode (Build with Bazel mode) requires apple_support 2.0.0+ and rules_swift 3.4.1+.The language to set in the scheme’s test options (e.g.
"en", "fr"). Defaults to system settings when not set.The region to set in the scheme’s test options (e.g.
"US", "GB"). Defaults to system settings when not set.