By default, rules_xcodeproj auto-generates an Xcode scheme for every buildable target in your project. This is convenient for getting started, but for production projects you typically need more control: grouping targets into a single scheme, setting launch arguments, customizing the test action, or suppressing schemes for internal library targets. 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 gives you that full control by letting you define every aspect of an Xcode scheme directly in your BUILD file.
Scheme autogeneration modes
Thescheme_autogeneration_mode attribute on the xcodeproj rule controls whether Xcode schemes are automatically generated alongside any custom schemes you define.
| Value | Behaviour |
|---|---|
"auto" | (Default) If no custom schemes are provided via xcschemes, a scheme is created for every buildable target. If any custom schemes are provided, no autogenerated schemes are created. |
"none" | No schemes are automatically generated, regardless of whether custom schemes are provided. |
"all" | A scheme is generated for every buildable target even if custom schemes are provided. |
"none" together with xcschemes to have complete, explicit control over what appears in the scheme menu.
A full working example
BUILD
:App and runs :Tests, suppressing all autogenerated schemes.
Scheme actions
A scheme can include up to three actions, each configured with its own constructor:- Run
- Test
- Profile
xcschemes.run defines the Run (and Debug) action. The most important field is launch_target, which must be a value from xcschemes.launch_target or xcschemes.launch_path.Arguments and environment variables
Usexcschemes.arg and xcschemes.env_value to set command-line arguments and environment variables for any action.
BUILD
xcschemes.arg accepts:
value— the argument string (required)enabled— whether the checkbox is checked in Xcode (defaultTrue)literal_string— ifTrue, spaces invalueare escaped so the whole string is treated as one argument (defaultTrue)
xcschemes.env_value accepts:
value— the environment variable value (required)enabled— whether the checkbox is checked in Xcode (defaultTrue)
Pre- and post-actions
You can run shell scripts before or after the Build or Run/Test/Profile phase using thexcschemes.pre_post_actions namespace.
BUILD
| Constructor | Where it appears in Xcode |
|---|---|
xcschemes.pre_post_actions.build_script | Pre/Post-actions of the Build section |
xcschemes.pre_post_actions.launch_script | Pre/Post-actions of the Run, Test, or Profile section |
title— displayed name in Xcode (default"Run Script")script_text— the shell script body (required)order— optional integer controlling relative ordering among actions
Scripts run in Bazel’s execution root, not the source directory. Add
cd "$SRCROOT" at the top of your script if you need to reference workspace-relative paths.Diagnostics
Enable runtime sanitizers for a scheme’s Run or Test action usingxcschemes.diagnostics:
BUILD
address_sanitizer, thread_sanitizer, undefined_behavior_sanitizer, main_thread_checker (default True), thread_performance_checker (default True). Note that address_sanitizer and thread_sanitizer are mutually exclusive.
Autogeneration config
For cases where you want autogenerated schemes but need to apply pre/post-actions or name filters globally, usexcschemes.autogeneration_config on the scheme_autogeneration_config attribute:
BUILD