To use these rules and macros in your BUILD
files, load
them from
xcodeproj/defs.bzl
.
For example, to use the xcodeproj
rule, you would need to use
this load
statement:
load("@rules_xcodeproj//xcodeproj:defs.bzl", "xcodeproj")
- Core
- Custom Xcode schemes (Incremental generation mode)
xcschemes.scheme
xcschemes.test
xcschemes.run
xcschemes.profile
xcschemes.launch_target
xcschemes.test_target
xcschemes.top_level_build_target
xcschemes.top_level_anchor_target
xcschemes.library_target
xcschemes.arg
xcschemes.env_value
xcschemes.pre_post_actions.build_script
xcschemes.pre_post_actions.launch_script
- Custom Xcode schemes (Legacy generation mode)
- Xcode build settings
- Providers
xcodeproj(name, adjust_schemes_for_swiftui_previews, archived_bundles_allowed, associated_extra_files, bazel_path, bazel_env, build_mode, config, default_xcode_configuration, extra_files, fail_for_invalid_extra_files_targets, focused_targets, install_directory, ios_device_cpus, ios_simulator_cpus, minimum_xcode_version, post_build, pre_build, project_name, project_options, scheme_autogeneration_mode, schemes, target_name_mode, temporary_directory, top_level_targets, tvos_device_cpus, tvos_simulator_cpus, unfocused_targets, watchos_device_cpus, watchos_simulator_cpus, xcode_configurations, xcschemes, kwargs)
Creates an .xcodeproj
file in the workspace when run.
This is a wrapper macro for the
actual xcodeproj
rule, which
can't be used directly. All public API is documented below. The kwargs
argument will pass forward values for globally available attributes (e.g.
visibility
, features
, etc.) to the underlying rule.
EXAMPLE
xcodeproj(
name = "xcodeproj",
project_name = "App",
tags = ["manual"],
top_level_targets = [
top_level_target(":App", target_environments = ["device", "simulator"]),
":Tests",
],
)
PARAMETERS
Name | Description | Default Value |
---|---|---|
name | A unique name for this target. | none |
adjust_schemes_for_swiftui_previews | Optional. Whether to adjust schemes in BwB mode to explicitly include transitive dependencies that are able to run Xcode Previews. For example, this changes a scheme for an single application target to also include any app clip, app extension, framework, or watchOS app dependencies. |
True |
archived_bundles_allowed | This argument is deprecated and is now a no-op. It will be removed in a future release. Adjust the setting of --define=apple.experimental.tree_artifact_outputs on build:rules_xcodeproj in your .bazelrc or xcodeproj.bazelrc file. |
None |
associated_extra_files | Optional. A dict of files to be added to the project.The key is a string value representing the label of the target the files should be associated with, and the value is a list of File s. These files won't be added to the project if the target is unfocused. |
{} |
bazel_path | Optional. The path the bazel binary or wrapper script.If the path is relative it will be resolved using the PATH environment variable that is set when generating the project. If you want to specify a path to a workspace-relative binary, you must prepend the path with ./ (e.g. "./bazelw" ). |
"bazel" |
bazel_env | Optional. A dict of environment variables to set when invoking bazel_path .This is useful for setting environment variables that are required for Bazel actions to run successfully, such as JAVA_HOME or ANDROID_HOME . It's also useful if bazel_path itself (if it's a wrapper) needs certain environment variables.The keys are the names of the environment variables, and the values are the values of the environment variables. If a value is None , the environment variable will be picked up from the current environment.If project generation succeeds, but building inside of Xcode fails because of missing environment variables, you probably have to set them here. If PATH is not specified, it will default to /bin:/usr/bin , so you don't have to specify it unless you want to use a different value. |
{"PATH": "/bin:/usr/bin"} |
build_mode | Optional. The build mode the generated project should use. If this is set to "xcode" , the project will use the Xcode build system to build targets. Generated files and unfocused targets (see the focused_targets and unfocused_targets arguments) will be built with Bazel.If this is set to "bazel" , the project will use Bazel to build targets, inside of Xcode. The Xcode build system still unavoidably orchestrates some things at a high level. |
"bazel" |
config | Optional. The Bazel config to use when generating the project or invoking bazel inside of Xcode.This is the basename of multiple configs. For example, if this is set to "projectx_xcodeproj" , then the following configs will be available for you to adjust in your .bazelrc file:
See the usage guide for more information on adjusting Bazel configs. |
"rules_xcodeproj" |
default_xcode_configuration | Optional. The name of the the Xcode configuration to use when building, if not overridden by custom schemes. If not set, the first Xcode configuration alphabetically will be used. Use xcode_configurations to adjust Xcode configurations. |
None |
extra_files | Optional. A list of extra File s to be added to the project. |
[] |
fail_for_invalid_extra_files_targets | Optional. Determines wether, when processing targets, invalid extra files without labels will fail or just emit a warning. | True |
focused_targets | Optional. A list of target labels as string values.If specified, only these targets will be included in the generated project; all other targets will be excluded, as if they were listed explicitly in the unfocused_targets argument. The labels must match transitive dependencies of the targets specified in the top_level_targets argument. |
[] |
install_directory | Optional. The directory where the generated project will be written to. The path is relative to the workspace root. Defaults to the directory that the xcodeproj target is declared in (e.g. if the xcodeproj target is declared in //foo/bar:BUILD then the default value is "foo/bar" ). Use "" to have the project generated in the workspace root. |
None |
ios_device_cpus | Optional. The value to use for --ios_multi_cpus when building the transitive dependencies of the targets specified in the top_level_targets argument with the "device" target_environment .Warning: Changing this value will affect the Starlark transition hash of all transitive dependencies of the targets specified in the top_level_targets argument with the "device" target_environment , even if they aren't iOS targets. |
"arm64" |
ios_simulator_cpus | Optional. The value to use for --ios_multi_cpus when building the transitive dependencies of the targets specified in the top_level_targets argument with the "simulator" target_environment .If no value is specified, it defaults to the simulator cpu that goes with --host_cpu (i.e. sim_arm64 on Apple Silicon and x86_64 on Intel).Warning: Changing this value will affect the Starlark transition hash of all transitive dependencies of the targets specified in the top_level_targets argument with the "simulator" target_environment , even if they aren't iOS targets. |
None |
minimum_xcode_version | Optional. The minimum Xcode version that the generated project supports. Newer Xcode versions can support newer features, so setting this to the highest value you can will enable the most features. The value is the dot separated version number (e.g. "13.4.1", "14", "14.1"). Defaults to whichever version of Xcode that Bazel uses during project generation. |
None |
post_build | The text of a script that will be run after the build. For example: ./post-build.sh , "$SRCROOT/post-build.sh" .The script will be run in Bazel's execution root, so you probably want to change to the $SRCROOT directory in the script.Currently this script will be run as part of Index Build. If you don't want that (which is probably the case), you should add a check to ensure $ACTION == build . |
None |
pre_build | The text of a script that will be run before the build. For example: ./pre-build.sh , "$SRCROOT/pre-build.sh" .The script will be run in Bazel's execution root, so you probably want to change to the $SRCROOT directory in the script.Currently this script will be run as part of Index Build. If you don't want that (which is probably the case), you should add a check to ensure $ACTION == build . |
None |
project_name | Optional. The name to use for the .xcodeproj file.If not specified, the value of the name argument is used. |
None |
project_options | Optional. A value returned by project_options . |
None |
scheme_autogeneration_mode | Optional. Specifies how Xcode schemes are automatically generated:
|
"auto" |
schemes | Optional. A list of values returned by xcode_schemes.scheme .This and the scheme_autogeneration_mode argument together customize how schemes for targets are generated, when using generation_mode = "legacy" .Target labels listed in the schemes need to be from the transitive dependencies of the targets specified in the top_level_targets argument. |
[] |
target_name_mode | Optional. Specifies how Xcode targets names are represented:
|
"auto" |
temporary_directory | This argument is deprecated and is now a no-op. It will be removed in a future release. | None |
top_level_targets | A list of a list of top-level targets.Each target can be specified as either a Label (or label-like string ), a value returned by top_level_target , or a value returned by top_level_targets . |
none |
tvos_device_cpus | Optional. The value to use for --tvos_cpus when building the transitive dependencies of the targets specified in the top_level_targets argument with the "device" target_environment .Warning: Changing this value will affect the Starlark transition hash of all transitive dependencies of the targets specified in the top_level_targets argument with the "device" target_environment , even if they aren't tvOS targets. |
"arm64" |
tvos_simulator_cpus | Optional. The value to use for --tvos_cpus when building the transitive dependencies of the targets specified in the top_level_targets argument with the "simulator" target_environment .If no value is specified, it defaults to the simulator cpu that goes with --host_cpu (i.e. sim_arm64 on Apple Silicon and x86_64 on Intel).Warning: Changing this value will affect the Starlark transition hash of all transitive dependencies of the targets specified in the top_level_targets argument with the "simulator" target_environment , even if they aren't tvOS targets. |
None |
unfocused_targets | Optional. A list of target labels as string values.Any targets in the transitive dependencies of the targets specified in the top_level_targets argument with a matching label will be excluded from the generated project. This overrides any targets specified in the focused_targets argument. |
[] |
watchos_device_cpus | Optional. The value to use for --watchos_cpus when building the transitive dependencies of the targets specified in the top_level_targets argument with the "device" target_environment .Warning: Changing this value will affect the Starlark transition hash of all transitive dependencies of the targets specified in the top_level_targets argument with the "device" target_environment , even if they aren't watchOS targets. |
"arm64_32" |
watchos_simulator_cpus | Optional. The value to use for --watchos_cpus when building the transitive dependencies of the targets specified in the top_level_targets argument with the "simulator" target_environment .If no value is specified, it defaults to the simulator cpu that goes with --host_cpu (i.e. arm64 on Apple Silicon and x86_64 on Intel).Warning: Changing this value will affect the Starlark transition hash of all transitive dependencies of the targets specified in the top_level_targets argument with the "simulator" target_environment , even if they aren't watchOS targets. |
None |
xcode_configurations | Optional. A dict mapping Xcode configuration names to transition settings dictionaries. For example:
would create the "Dev" and "AppStore" configurations, setting --compilation_mode to dbg and opt respectively.Refer to the bazel documentation on how to define the transition settings dictionary. |
{"Debug": {}} |
xcschemes | Optional. A list of values returned by xcschemes.scheme .This and the scheme_autogeneration_mode argument together customize how schemes for targets are generated, when using generation_mode = "incremental" . |
[] |
kwargs | Additional arguments to pass to the underlying xcodeproj rule specified by xcodeproj_rule . |
none |
top_level_target(label, target_environments)
Constructs a top-level target for use in xcodeproj.top_level_targets
.
PARAMETERS
RETURNS
A struct
containing fields for the provided arguments.
top_level_targets(labels, target_environments)
Constructs a list of top-level target for use in xcodeproj.top_level_targets
.
PARAMETERS
Name | Description | Default Value |
---|---|---|
labels | A list of Label or label-like string for the targets. |
none |
target_environments | Optional. See top_level_target.target_environments . |
["simulator"] |
RETURNS
A list
of values from top_level_target
.
project_options(development_region, indent_width, organization_name, tab_width, uses_tabs)
Project options for use in xcodeproj.project_options
.
PARAMETERS
RETURNS
A dict
containing fields for the provided arguments.
To use these functions, load
the xcschemes
module from xcodeproj/defs.bzl
:
load("@rules_xcodeproj//xcodeproj:defs.bzl", "xcschemes")
xcschemes.arg(value, enabled)
Defines a command-line argument.
PARAMETERS
xcschemes.diagnostics(address_sanitizer, thread_sanitizer, undefined_behavior_sanitizer)
Defines the diagnostics to enable.
PARAMETERS
Name | Description | Default Value |
---|---|---|
address_sanitizer | Whether to enable Address Sanitizer. If True , thread_sanitizer must be `False. |
False |
thread_sanitizer | Whether to enable Thread Sanitizer. If True , address_sanitizer must be `False. |
False |
undefined_behavior_sanitizer | Whether to enable Undefined Behavior Sanitizer. | False |
xcschemes.env_value(value, enabled)
Defines an environment variable value.
PARAMETERS
xcschemes.launch_path(path, post_actions, pre_actions, working_directory)
Defines the launch path for a pre-built executable.
PARAMETERS
Name | Description | Default Value |
---|---|---|
path | Positional. The launch path for a launch target. The path must be an absolute path to an executable file. It will be set as the runnable within a launch action. |
none |
post_actions | Post-actions to run when running the launch path. Elements of the list must be values returned by functions in xcschemes.pre_post_actions . |
[] |
pre_actions | Pre-actions to run when running the launch path. Elements of the list must be values returned by functions in xcschemes.pre_post_actions . |
[] |
working_directory | The working directory to use when running the launch target. If not set, the Xcode default working directory will be used (i.e. some directory in DerivedData ). |
None |
xcschemes.launch_target(label, extension_host, library_targets, post_actions, pre_actions, target_environment, working_directory)
Defines a launch target.
PARAMETERS
Name | Description | Default Value |
---|---|---|
label | Positional. The label string of the target to launch when running. | none |
extension_host | The label string of an extension host for the launch target. If label is an app extension, this must be set to the label string of a target that bundles the app extension. Otherwise, this must be None . |
None |
library_targets | Additional library targets to build when running. Library targets must be transitive dependencies of the launch target. Each element of the list can be a label string or a value returned by xcschemes.library_target . If an element is a label string, it will be transformed into xcschemes.library_target(label_str) . For example,
|
[] |
post_actions | Post-actions to run when building or running the launch target. Elements of the list must be values returned by functions in xcschemes.pre_post_actions . |
[] |
pre_actions | Pre-actions to run when building or running the launch target. Elements of the list must be values returned by functions in xcschemes.pre_post_actions . |
[] |
target_environment | The target environment to use when determining which version of the launch target label refers to.If not set, the default target environment will be used (i.e. "simulator" if it's one of the available target environments, otherwise "device" ). |
None |
working_directory | The working directory to use when running the launch target. If not set, the Xcode default working directory will be used (i.e. some directory in DerivedData ). |
None |
xcschemes.library_target(label, post_actions, pre_actions)
Defines a library target to build.
PARAMETERS
Name | Description | Default Value |
---|---|---|
label | Positional. The label string of the library target. This must be a library target (i.e. not a top-level target); use the build_targets attribute of profile , run , or test to add top-level build targets. |
none |
post_actions | Post-actions to run when building or running the action this build target is a part of. Elements of the list must be values returned by functions in xcschemes.pre_post_actions . |
[] |
pre_actions | Pre-actions to run when building or running the action this build target is a part of. Elements of the list must be values returned by functions in xcschemes.pre_post_actions . |
[] |
xcschemes.pre_post_actions.build_script(title, order, script_text)
Defines a pre-action or post-action script to run when building.
This action will appear in the Pre-actions or Post-actions section of the Build section of the scheme.
PARAMETERS
xcschemes.pre_post_actions.launch_script(title, order, script_text)
Defines a pre-action or post-action script to run when running.
This action will appear in the Pre-actions or Post-actions section of the Test, Run, or Profile section of the scheme.
PARAMETERS
xcschemes.profile(args, build_targets, env, env_include_defaults, launch_target, use_run_args_and_env, xcode_configuration)
Defines the Profile action.
PARAMETERS
Name | Description | Default Value |
---|---|---|
args | Command-line arguments to use when profiling the launch target. If "inherit" , then the arguments will be supplied by the launch target (e.g. cc_binary.args ). Otherwise, the list of arguments will be set as provided, and None or [] will result in no command-line arguments.Each element of the list can either be a string or a value returned by xcschemes.arg . If an element is a string, it will be transformed into xcschemes.arg(element) . For example,
|
"inherit" |
build_targets | Additional targets to build when profiling. Each element of the list can be a label string, a value returned by xcschemes.top_level_build_target , or a value returned by xcschemes.top_level_anchor_target . If an element is a label string, it will be transformed into xcschemes.top_level_build_target(label_str) . For example,
|
[] |
env | Environment variables to use when profiling the launch target. If set to "inherit" , then the environment variables will be supplied by the launch target (e.g. cc_binary.env ). Otherwise, the dict of environment variables will be set as provided, and None or {} will result in no environment variables.Each value of the dict can either be a string or a value returned by xcschemes.env_value . If a value is a string, it will be transformed into xcschemes.env_value(value) . For example,
|
"inherit" |
env_include_defaults | Whether to include the rules_xcodeproj provided default Bazel environment variables (e.g. BUILD_WORKING_DIRECTORY and BUILD_WORKSPACE_DIRECTORY ), in addition to any set by env . This does not apply to xcschemes.launch_path s. |
True |
launch_target | The target to launch when profiling. Can be None , a label string, a value returned by xcschemes.launch_target , or a value returned by xcschemes.launch_path . If a label string, xcschemes.launch_target(label_str) will be used. If None , xcschemes.launch_target() will be used, which means no launch target will be set (i.e. the Executable dropdown will be set to None ). |
None |
use_run_args_and_env | Whether the Use the Run action's arguments and environment variables checkbox is checked.If True , command-line arguments and environment variables will still be set as defined by args and env , but will be ignored by Xcode unless you manually uncheck this checkbox in the scheme. If None , True will be used if args and env are both "inherit" , otherwise False will be used.A value of True will be ignored (i.e. treated as False ) if run.launch_target is not set to a target. |
None |
xcode_configuration | The name of the Xcode configuration to use to build the targets referenced in the Profile action (i.e in the build_targets and launch_target attributes).If not set, the value of xcodeproj.default_xcode_configuration is used. |
None |
xcschemes.run(args, build_targets, diagnostics, env, env_include_defaults, launch_target, xcode_configuration)
Defines the Run action.
PARAMETERS
Name | Description | Default Value |
---|---|---|
args | Command-line arguments to use when running the launch target. If "inherit" , then the arguments will be supplied by the launch target (e.g. cc_binary.args ). Otherwise, the list of arguments will be set as provided, and None or [] will result in no command-line arguments.Each element of the list can either be a string or a value returned by xcschemes.arg . If an element is a string, it will be transformed into xcschemes.arg(element) . For example,
|
"inherit" |
build_targets | Additional targets to build when running. Each element of the list can be a label string, a value returned by xcschemes.top_level_build_target , or a value returned by xcschemes.top_level_anchor_target . If an element is a label string, it will be transformed into xcschemes.top_level_build_target(label_str) . For example,
|
[] |
diagnostics | The diagnostics to enable when running the launch target. Can be None or a value returned by xcschemes.diagnostics . If None , xcschemes.diagnostics() will be used, which means no diagnostics will be enabled. |
None |
env | Environment variables to use when running the launch target. If set to "inherit" , then the environment variables will be supplied by the launch target (e.g. cc_binary.env ). Otherwise, the dict of environment variables will be set as provided, and None or {} will result in no environment variables.Each value of the dict can either be a string or a value returned by xcschemes.env_value . If a value is a string, it will be transformed into xcschemes.env_value(value) . For example,
|
"inherit" |
env_include_defaults | Whether to include the rules_xcodeproj provided default Bazel environment variables (e.g. BUILD_WORKING_DIRECTORY and BUILD_WORKSPACE_DIRECTORY ), in addition to any set by env . This does not apply to xcschemes.launch_path s. |
True |
launch_target | The target to launch when running. Can be None , a label string, a value returned by xcschemes.launch_target , or a value returned by xcschemes.launch_path . If a label string, xcschemes.launch_target(label_str) will be used. If None , xcschemes.launch_target() will be used, which means no launch target will be set (i.e. the Executable dropdown will be set to None ). |
None |
xcode_configuration | The name of the Xcode configuration to use to build the targets referenced in the Run action (i.e in the build_targets and launch_target attributes).If not set, the value of xcodeproj.default_xcode_configuration is used. |
None |
xcschemes.scheme(name, profile, run, test)
Defines a custom scheme.
PARAMETERS
Name | Description | Default Value |
---|---|---|
name | Positional. The name of the scheme. | none |
profile | A value returned by xcschemes.profile , or the string "same_as_run" .If "same_as_run" , the same targets will be built for the Profile action as are built for the Run action (defined by xcschemes.run ). If None , xcschemes.profile() will be used, which means no targets will be built for the Profile action. |
"same_as_run" |
run | A value returned by xcschemes.run .If None , xcschemes.run() will be used, which means no targets will be built for the Run action, except for build_targets and library_targets specified in xcschemes.profile and xcschemes.test . |
None |
test | A value returned by xcschemes.test .If None , xcschemes.test() will be used, which means no targets will be built for the Test action. |
None |
xcschemes.test(args, build_targets, diagnostics, env, env_include_defaults, test_targets, use_run_args_and_env, xcode_configuration)
Defines the Test action.
PARAMETERS
Name | Description | Default Value |
---|---|---|
args | Command-line arguments to use when testing. If "inherit" , then the arguments will be supplied by the test targets (e.g. cc_test.args ), as long as every test target has the same arguments. Otherwise, the list of arguments will be set as provided, and None or [] will result in no command-line arguments.Each element of the list can either be a string or a value returned by xcschemes.arg . If an element is a string, it will be transformed into xcschemes.arg(element) . For example,
|
"inherit" |
build_targets | Additional targets to build when testing. Each element of the list can be a label string, a value returned by xcschemes.top_level_build_target , or a value returned by xcschemes.top_level_anchor_target . If an element is a label string, it will be transformed into xcschemes.top_level_build_target(label_str) . For example,
|
[] |
diagnostics | The diagnostics to enable when testing. Can be None or a value returned by xcschemes.diagnostics . If None , xcschemes.diagnostics() will be used, which means no diagnostics will be enabled. |
None |
env | Environment variables to use when testing. If set to "inherit" , then the environment variables will be supplied by the test targets (e.g. ios_unit_test.env ), as long as every test target has the same environment variables. Otherwise, the dict of environment variables will be set as provided, and None or {} will result in no environment variables.Each value of the dict can either be a string or a value returned by xcschemes.env_value . If a value is a string, it will be transformed into xcschemes.env_value(value) . For example,
|
"inherit" |
env_include_defaults | Whether to include the rules_xcodeproj provided default Bazel environment variables (e.g. BUILD_WORKING_DIRECTORY and BUILD_WORKSPACE_DIRECTORY ), in addition to any set by env . |
True |
test_targets | The test targets to build, and possibly run, when testing. Each element of the list can be a label string or a value returned by xcschemes.test_target . If an element is a label string, it will be transformed into xcschemes.test_target(label_str) . For example,
|
[] |
use_run_args_and_env | Whether the Use the Run action's arguments and environment variables checkbox is checked.If True , command-line arguments and environment variables will still be set as defined by args and env , but will be ignored by Xcode unless you manually uncheck this checkbox in the scheme. If None , True will be used if args and env are both "inherit" , otherwise False will be used.A value of True will be ignored (i.e. treated as False ) if run.launch_target is not set to a target. |
None |
xcode_configuration | The name of the Xcode configuration to use to build the targets referenced in the Test action (i.e in the build_targets and test_targets attributes).If not set, the value of xcodeproj.default_xcode_configuration is used. |
None |
xcschemes.test_target(label, enabled, library_targets, post_actions, pre_actions, target_environment)
Defines a test target.
PARAMETERS
Name | Description | Default Value |
---|---|---|
label | Positional. The label string of the test target. | none |
enabled | Whether the test target is enabled. If True , the checkbox for the test target will be checked in the scheme. An unchecked checkbox means Xcode won't run this test target when testing. |
True |
library_targets | Additional library targets to build when testing. Library targets must be transitive dependencies of the test target. They must not be top-level targets; use build_targets for those.Each element of the list can be a label string or a value returned by xcschemes.library_target . If an element is a label string, it will be transformed into xcschemes.library_target(label_str) . For example,
|
[] |
post_actions | Post-actions to run when building or running the test target. Elements of the list must be values returned by functions in xcschemes.pre_post_actions . |
[] |
pre_actions | Pre-actions to run when building or running the test target. Elements of the list must be values returned by functions in xcschemes.pre_post_actions . |
[] |
target_environment | The target environment to use when determining which version of the test target label refers to.If not set, the default target environment will be used (i.e. "simulator" if it's one of the available target environments, otherwise "device" ). |
None |
xcschemes.top_level_anchor_target(label, extension_host, library_targets, target_environment)
Defines a top-level anchor target for library build targets.
Use this function to define library targets to build, when you don't want
to also build the top-level target that depends on them. If you also want to
build the top-level target, use
top_level_build_target
instead.
PARAMETERS
Name | Description | Default Value |
---|---|---|
label | Positional. The label string of the top-level target. This must be a top-level target (i.e. not a library target); use the library_targets attribute of launch_target , test_target , top_level_anchor_target , or top_level_build_target to add library build targets. |
none |
extension_host | The label string of an extension host for the top-level target. If label is an app extension, this must be set to the label string of a target that bundles the app extension. Otherwise, this must be None . |
None |
library_targets | The library targets to build. Library targets must be transitive dependencies of the top-level anchor target. They must not be top-level targets; instead, set additional values in the build_targets attribute that this top_level_build_target is defined in.Each element of the list can be a label string or a value returned by xcschemes.library_target . If an element is a label string, it will be transformed into xcschemes.library_target(label_str) . For example,
|
none |
target_environment | The target environment to use when determining which version of the top-level target label refers to.If not set, the default target environment will be used (i.e. "simulator" if it's one of the available target environments, otherwise "device" ). |
None |
xcschemes.top_level_build_target(label, extension_host, library_targets, post_actions, pre_actions, target_environment)
Defines a top-level target to build.
Use this function to define a top-level target, and optionally transitive
library targets, to build. If you don't want to build the top-level target,
and only want to build the transitive library targets, use
top_level_anchor_target
instead.
PARAMETERS
Name | Description | Default Value |
---|---|---|
label | Positional. The label string of the top-level target. This must be a top-level target (i.e. not a library target); use the library_targets attribute of launch_target , test_target , top_level_build_target , or top_level_anchor_target to add library build targets. |
none |
extension_host | The label string of an extension host for the top-level target. If label is an app extension, this must be set to the label string of a target that bundles the app extension. Otherwise, this must be None . |
None |
library_targets | Additional library targets to build. Library targets must be transitive dependencies of the top-level build target. They must not be top-level targets; instead, set additional values in the build_targets attribute that this top_level_build_target is defined in.Each element of the list can be a label string or a value returned by xcschemes.library_target . If an element is a label string, it will be transformed into xcschemes.library_target(label_str) . For example,
|
[] |
post_actions | Post-actions to run when building or running the action this build target is a part of. Elements of the list must be values returned by functions in xcschemes.pre_post_actions . |
[] |
pre_actions | Pre-actions to run when building or running the action this build target is a part of. Elements of the list must be values returned by functions in xcschemes.pre_post_actions . |
[] |
target_environment | The target environment to use when determining which version of the top-level target label refers to.If not set, the default target environment will be used (i.e. "simulator" if it's one of the available target environments, otherwise "device" ). |
None |
To use these functions, load
the xcode_schemes
module from
xcodeproj/defs.bzl
:
load("@rules_xcodeproj//xcodeproj:defs.bzl", "xcode_schemes")
xcode_schemes.build_action(targets, pre_actions, post_actions)
Constructs a build action for an Xcode scheme.
PARAMETERS
RETURNS
A struct
representing a build action.
xcode_schemes.build_for(running, testing, profiling, archiving, analyzing)
Construct a struct
representing the settings that dictate when Xcode will build a target.
PARAMETERS
RETURNS
A struct
.
xcode_schemes.build_target(label, build_for)
Constructs a build target for an Xcode scheme's build action.
PARAMETERS
RETURNS
A struct
representing a build target.
xcode_schemes.diagnostics(sanitizers)
Constructs the scheme's diagnostics.
PARAMETERS
Name | Description | Default Value |
---|---|---|
sanitizers | Optional. A struct value as created by xcode_schemes.sanitizers . |
None |
RETURNS
A struct
representing scheme's diagnostics.
xcode_schemes.launch_action(target, args, build_configuration, diagnostics, env, working_directory)
Constructs a launch action for an Xcode scheme.
PARAMETERS
RETURNS
A struct
representing a launch action.
xcode_schemes.pre_post_action(name, script, expand_variables_based_on)
Constructs a pre or post action for a step of the scheme.
PARAMETERS
RETURNS
A struct
representing a scheme's step pre or post action.
xcode_schemes.profile_action(target, args, build_configuration, env, working_directory)
Constructs a profile action for an Xcode scheme.
PARAMETERS
RETURNS
A struct
representing a profile action.
xcode_schemes.sanitizers(address, thread, undefined_behavior)
Constructs the scheme's sanitizers' default state. The state can also be modified in Xcode.
PARAMETERS
xcode_schemes.scheme(name, build_action, launch_action, profile_action, test_action)
Returns a struct
representing an Xcode scheme.
PARAMETERS
RETURNS
A struct
representing an Xcode scheme.
xcode_schemes.test_action(targets, args, build_configuration, diagnostics, env, expand_variables_based_on, pre_actions, post_actions)
Constructs a test action for an Xcode scheme.
PARAMETERS
RETURNS
A struct
representing a test action.
Rules that provide additional information to the xcodeproj
rule,
so that it can properly determine values for various Xcode build settings.
xcode_provisioning_profile(name, managed_by_xcode, profile_name, provisioning_profile, team_id)
This rule declares a target that you can pass to the provisioning_profile
attribute of rules that require it. It wraps another provisioning profile
target, either a File
or a rule like rules_apple's
local_provisioning_profile
, and allows specifying additional information to
adjust Xcode related build settings related to code signing.
If you are already using local_provisioning_profile
, or another rule that
returns the AppleProvisioningProfileInfo
provider, you don't need to use this
rule, unless you want to enable Xcode's "Automatic Code Signing" feature. If you
are using a File
, then this rule is needed in order to set the
DEVELOPER_TEAM
build setting via the team_id
attribute.
EXAMPLE
ios_application(
...
provisioning_profile = ":xcode_profile",
...
)
xcode_provisioning_profile(
name = "xcode_profile",
managed_by_xcode = True,
provisioning_profile = ":provisioning_profile",
)
local_provisioning_profile(
name = "provisioning_profile",
profile_name = "iOS Team Provisioning Profile: com.example.app",
team_id = "A12B3CDEFG",
)
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
managed_by_xcode | Whether the provisioning profile is managed by Xcode. If True , "Automatic Code Signing" will be enabled in Xcode, and the profile name will be ignored. Xcode will add devices to profiles automatically via the currently logged in Apple Developer Account, and otherwise fully manage the profile. If False , "Manual Code Signing" will be enabled in Xcode, and the profile name will be used to determine which profile to use.If xcodeproj.build_mode != "xcode" , then Xcode will still manage the profile when this is True , but otherwise won't use it to actually sign the binary. Instead Bazel will perform the code signing with the file set to provisioning_profile . Using rules_apple's local_provisioning_profile as the target set to provisioning_profile will then allow Bazel to code sign with the Xcode managed profile. |
Boolean | required | |
profile_name | When managed_by_xcode is False , the PROVISIONING_PROFILE_SPECIFIER Xcode build setting will be set to this value. If this is None (the default), and provisioning_profile returns the AppleProvisioningProfileInfo provider (as local_provisioning_profile does), then AppleProvisioningProfileInfo.profile_name will be used instead. |
String | optional | "" |
provisioning_profile | The File that Bazel will use when code signing. If the target returns the AppleProvisioningProfileInfo provider (as local_provisioning_profile does), then it will provide default values for profile_name and team_id .When xcodeproj.build_mode = "xcode" , the actual file isn't used directly by Xcode, but in order to satisfy Bazel constraints this can't be None . |
Label | required | |
team_id | The DEVELOPER_TEAM Xcode build setting will be set to this value. If this is None (the default), and provisioning_profile returns the AppleProvisioningProfileInfo provider (as local_provisioning_profile does), then AppleProvisioningProfileInfo.team_id will be used instead. |
String | optional | "" |
Providers that are used throughout the rules in this repository.
Most users will not need to use these providers to simply create Xcode projects, but if you want to write your own custom rules that interact with these rules, then you will use these providers to communicate between them.
XcodeProjAutomaticTargetProcessingInfo(alternate_icons, app_icons, args, bundle_id, codesign_inputs, codesignopts, collect_uncategorized_files, deps, entitlements, env, exported_symbols_lists, hdrs, implementation_deps, infoplists, is_supported, is_top_level, label, launchdplists, link_mnemonics, non_arc_srcs, pch, provisioning_profile, should_generate, srcs, target_type, xcode_targets)
Provides needed information about a target to allow rules_xcodeproj to automatically process it.
If you need more control over how a target or its dependencies are processed,
return an XcodeProjInfo
provider instance instead.
Warning
This provider currently has an unstable API and may change in the future. If you are using this provider, please let us know so we can prioritize stabilizing it.
FIELDS
XcodeProjInfo(args, compilation_providers, direct_dependencies, envs, extension_infoplists, focused_library_deps, framework_product_mappings, hosted_targets, inputs, label, labels, lldb_context, mergable_xcode_library_targets, mergeable_infos, merged_target_ids, non_top_level_rule_kind, outputs, platforms, potential_target_merges, replacement_labels, resource_bundle_ids, swift_debug_settings, target_output_groups, target_type, top_level_focused_deps, top_level_swift_debug_settings, transitive_dependencies, xcode_required_targets, xcode_target, xcode_targets)
Provides information needed to generate an Xcode project.
Warning
This provider currently has an unstable API and may change in the future. If you are using this provider, please let us know so we can prioritize stabilizing it.
FIELDS