Skip to content

Latest commit

 

History

History
executable file
·
1045 lines (709 loc) · 107 KB

bazel.md

File metadata and controls

executable file
·
1045 lines (709 loc) · 107 KB

Bazel rules and macros

Usage

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")

Index

Core

xcodeproj

xcodeproj(name, adjust_schemes_for_swiftui_previews, associated_extra_files, bazel_path, bazel_env,
          build_mode, config, default_xcode_configuration, extra_files,
          fail_for_invalid_extra_files_targets, focused_targets, generation_mode,
          import_index_build_indexstores, install_directory, ios_device_cpus, ios_simulator_cpus,
          minimum_xcode_version, post_build, pre_build, project_name, project_options,
          scheme_autogeneration_mode, scheme_autogeneration_config, schemes, target_name_mode,
          top_level_targets, tvos_device_cpus, tvos_simulator_cpus, unfocused_targets,
          visionos_device_cpus, visionos_simulator_cpus, 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.

This is only used when generation_mode = "legacy".
True
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 Files. 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 resolved from the current environment as the project is generated. If a value references environment variables, those will be resolved from the current environment as the project is generated. If you want to use a literal $ in a value, you must escape it with two backslashes.

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.

  • 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.
  • xcode: The project will use the Xcode build system to build targets. Generated files and unfocused targets (see the focused_targets and unfocused_targets attributes) will be built with Bazel.

    Note: This mode is does not work with Bazel 7+.

    Note: This mode is does not work with generation_mode = "incremental".

    Note: This mode is deprecated and will be removed in a future version of rules_xcodeproj.
"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:

  • projectx_xcodeproj
  • projectx_xcodeproj_generator
  • projectx_xcodeproj_indexbuild
  • projectx_xcodeproj_swiftuipreviews


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 Files 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.
[]
generation_mode Optional. Determines how the project is generated.

  • incremental: The project is generated in pieces by multiple Bazel actions and then combined together. This allows for incremental generation where some of those pieces can be reused in subsequent project generations.

    The way information is collected and processed has also changed compared to legacy generation mode. This has resulted in some bug fixes and improvements that don't exist in legacy generation mode.

    Note: Only build_mode = "bazel" is supported in this mode.

    Note: The xcschemes attribute is used instead of schemes in this mode.
  • legacy: The project is generated by a monolith Bazel action.

    This mode is deprecated and will be removed in a future version of rules_xcodeproj.
"incremental"
import_index_build_indexstores Optional. Whether to import the index stores generated by Index Build.

This is useful if you want to use the index stores generated by Index Build to speed up Xcode's indexing process. You may not want this enabled if the additional work (mainly disk IO) of importing the index stores is not worth it for your project.

This only applies when using generation_mode = "incremental".
True
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: If no custom schemes are specified, via schemes, an Xcode scheme will be created for every buildable target. If custom schemes are provided, no autogenerated schemes will be created.
  • none: No schemes are automatically generated.
  • all: A scheme is generated for every buildable target even if custom schemes are provided.
"auto"
scheme_autogeneration_config Optional. A value returned by xcschemes.autogeneration_config.

Allows further configuration of scheme_autogeneration_mode.
{}
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: Use the product name if it is available and there is no collision. Otherwise select the target name from the label. And if there is a collision, use the full label.
  • label: Always use full label for Xcode targets names.
"auto"
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.
[]
visionos_device_cpus Optional. The value to use for --visionos_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 visionOS targets.
"arm64"
visionos_simulator_cpus Optional. The value to use for --visionos_cpus when building the transitive dependencies of the targets specified in the top_level_targets argument with the "simulator" 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 "simulator" target_environment, even if they aren't visionOS targets.
"sim_arm64"
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:

{
    "Dev": {
        "//command_line_option:compilation_mode": "dbg",
    },
    "AppStore": {
        "//command_line_option:compilation_mode": "opt",
    },
}


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

top_level_target(label, target_environments)

Constructs a top-level target for use in xcodeproj.top_level_targets.

PARAMETERS

Name Description Default Value
label A Label or label-like string for the target. none
target_environments Optional. A list of target environment strings (see @build_bazel_apple_support//constraints:target_environment; "catalyst" is not currently supported). The target will be configured for each environment.

If multiple environments are specified, then a single combined Xcode target will be created if possible. If the configured targets are the same for each environment (e.g. macOS for ["device", "simulator"]), they will appear as separate but similar Xcode targets. If no environments are specified, the "simulator" environment will be used.
["simulator"]

RETURNS

A struct containing fields for the provided arguments.

top_level_targets

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

project_options(development_region, indent_width, organization_name, tab_width, uses_tabs)

Project options for use in xcodeproj.project_options.

PARAMETERS

Name Description Default Value
development_region Optional. The development region for the project. "en"
indent_width Optional. The number of spaces to use for indentation. None
organization_name Optional. Populates the ORGANIZATIONNAME attribute for the project. None
tab_width Optional. The number of spaces to use for tabs. None
uses_tabs Optional. Whether to use tabs for indentation. None

RETURNS

A dict containing fields for the provided arguments.

Custom Xcode schemes (Incremental generation mode)

To use these functions, load the xcschemes module from xcodeproj/defs.bzl:

load("@rules_xcodeproj//xcodeproj:defs.bzl", "xcschemes")

xcschemes.arg

xcschemes.arg(value, enabled, literal_string)

Defines a command-line argument.

PARAMETERS

Name Description Default Value
value Positional. The command-line argument.

Arguments with quotes, spaces, or newlines will be escaped. You should not use additional quotes around arguments with spaces. If you include quotes around your argument, those quotes will be part of the argument.
none
enabled Whether the command-line argument is enabled.

If True, the checkbox for the argument will be checked in the scheme. An unchecked checkbox means Xcode won't include that argument when running a target.
True
literal_string Whether value should be interpreted as a literal string.

If True, any spaces will be escaped. This means that value will be passed to the launch target as a single string. If False, any spaces will not be escaped. This is useful to group multiple arguments under a single checkbox in Xcode.
True

xcschemes.autogeneration_config

xcschemes.autogeneration_config(scheme_name_exclude_patterns)

Creates a value for the scheme_autogeneration_config attribute of xcodeproj.

PARAMETERS

Name Description Default Value
scheme_name_exclude_patterns A list of regex patterns used to skip creating matching autogenerated schemes.

Example:

xcodeproj(
    ...
    scheme_name_exclude_patterns = xcschemes.autogeneration_config(
        scheme_name_exclude_patterns = [
            ".somePattern.",
            "^AnotherPattern.*",
        ],
    )
)
None

RETURNS

An opaque value for the scheme_autogeneration_config attribute of xcodeproj.

xcschemes.diagnostics

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

xcschemes.env_value(value, enabled)

Defines an environment variable value.

PARAMETERS

Name Description Default Value
value Positional. The environment variable value.

Values with quotes, spaces, or newlines will be escaped. You should not use additional quotes around values with spaces. If you include quotes around your value, those quotes will be part of the value.
none
enabled Whether the environment variable is enabled.

If True, the checkbox for the environment variable will be checked in the scheme. An unchecked checkbox means Xcode won't include that environment variable when running a target.
True

xcschemes.launch_path

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

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,
xcschemes.launch_target(
    …
    library_targets = [
        "//Modules/Lib1",
        xcschemes.library_target(
            "//Modules/Lib2",
            …
        ),
    ],
)
will be transformed into:
xcschemes.launch_target(
    …
    library_targets = [
        xcschemes.library_target("//Modules/Lib1"),
        xcschemes.library_target(
            "//Modules/Lib2",
            …
        ),
    ],
)
[]
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

xcschemes.library_target(label, post_actions, pre_actions)

Defines a library target to build.

A library target is any target not classified as a top-level target. Normally these targets are created with rules similar to swift_library or objc_library.

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

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

Name Description Default Value
title The title of the action. "Run Script"
order The relative order of the action within the section it appears in.

If None, the action will be added to the end of the section, in an unspecified but deterministic order. Otherwise, the order should be an integer. Smaller order values will run before larger order values. rules_xcodeproj created actions (e.g. "Update .lldbinit and copy dSYMs") use order values 0, -100, -200, etc.
None
script_text The script text.

The script will be run in Bazel's execution root, so you probably want to change to the $SRCROOT directory in the script.
none

xcschemes.pre_post_actions.launch_script

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

Name Description Default Value
title The title of the action. "Run Script"
order The relative order of the action within the section it appears in.

If None, the action will be added to the end of the section, in an unspecified but deterministic order. Otherwise, the order should be an integer. Smaller order values will run before larger order values. rules_xcodeproj created actions (e.g. "Update .lldbinit and copy dSYMs") use order values 0, -100, -200, etc.
None
script_text The script text.

The script will be run in Bazel's execution root, so you probably want to change to the $SRCROOT directory in the script.
none

xcschemes.profile

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,
xcschemes.profile(
    args = [
        "-arg1",
        xcschemes.arg("-arg2", enabled = False),
    ],
)
will be transformed into:
xcschemes.profile(
    args = [
        xcschemes.arg("-arg1"),
        xcschemes.arg("-arg2", enabled = False),
    ],
)
"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,
xcschemes.profile(
    build_targets = [
        xcschemes.top_level_anchor_target(
            "//App",
            …
        ),
        "//App:Test",
        xcschemes.top_level_build_target(
            "//CommandLineTool",
            …
        ),
    ],
)
will be transformed into:
xcschemes.profile(
    build_targets = [
        xcschemes.top_level_anchor_target(
            "//App",
            …
        ),
        xcschemes.top_level_build_target("//App:Test"),
        xcschemes.top_level_build_target(
            "//CommandLineTool",
            …
        ),
    ],
)
[]
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,
xcschemes.profile(
    env = {
        "VAR1": "value 1",
        "VAR 2": xcschemes.env_value("value2", enabled = False),
    },
)
will be transformed into:
xcschemes.profile(
    env = {
        "VAR1": xcschemes.env_value("value 1"),
        "VAR 2": xcschemes.env_value("value2", enabled = False),
    },
)
"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_paths. 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

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,
xcschemes.run(
    args = [
        "-arg1",
        xcschemes.arg("-arg2", enabled = False),
    ],
)
will be transformed into:
xcschemes.run(
    args = [
        xcschemes.arg("-arg1"),
        xcschemes.arg("-arg2", enabled = False),
    ],
)
"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,
xcschemes.run(
    build_targets = [
        xcschemes.top_level_anchor_target(
            "//App",
            …
        ),
        "//App:Test",
        xcschemes.top_level_build_target(
            "//CommandLineTool",
            …
        ),
    ],
)
will be transformed into:
xcschemes.run(
    build_targets = [
        xcschemes.top_level_anchor_target(
            "//App",
            …
        ),
        xcschemes.top_level_build_target("//App:Test"),
        xcschemes.top_level_build_target(
            "//CommandLineTool",
            …
        ),
    ],
)
[]
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,
xcschemes.run(
    env = {
        "VAR1": "value 1",
        "VAR 2": xcschemes.env_value("value2", enabled = False),
    },
)
will be transformed into:
xcschemes.run(
    env = {
        "VAR1": xcschemes.env_value("value 1"),
        "VAR 2": xcschemes.env_value("value2", enabled = False),
    },
)
"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_paths. 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

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

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,
xcschemes.test(
    args = [
        "-arg1",
        xcschemes.arg("-arg2", enabled = False),
    ],
)
will be transformed into:
xcschemes.test(
    args = [
        xcschemes.arg("-arg1"),
        xcschemes.arg("-arg2", enabled = False),
    ],
)
"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,
xcschemes.test(
    build_targets = [
        xcschemes.top_level_anchor_target(
            "//App",
            …
        ),
        "//App:Test",
        xcschemes.top_level_build_target(
            "//CommandLineTool",
            …
        ),
    ],
)
will be transformed into:
xcschemes.test(
    build_targets = [
        xcschemes.top_level_anchor_target(
            "//App",
            …
        ),
        xcschemes.top_level_build_target("//App:Test"),
        xcschemes.top_level_build_target(
            "//CommandLineTool",
            …
        ),
    ],
)
[]
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,
xcschemes.test(
    env = {
        "VAR1": "value 1",
        "VAR 2": xcschemes.env_value("value2", enabled = False),
    },
)
will be transformed into:
xcschemes.test(
    env = {
        "VAR1": xcschemes.env_value("value 1"),
        "VAR 2": xcschemes.env_value("value2", enabled = False),
    },
)
"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,
xcschemes.test(
    test_targets = [
        "//App:Test1",
        xcschemes.test_target(
            "//App:Test2",
            …
        ),
    ],
)
will be transformed into:
xcschemes.test(
    test_targets = [
        xcschemes.test_target("//App:Test1"),
        xcschemes.test_target(
            "//App:Test2",
            …
        ),
    ],
)
[]
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

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,
xcschemes.test_target(
    …
    library_targets = [
        "//Modules/Lib1",
        xcschemes.library_target(
            "//Modules/Lib2",
            …
        ),
    ],
)
will be transformed into:
xcschemes.test_target(
    …
    library_targets = [
        xcschemes.library_target("//Modules/Lib1"),
        xcschemes.library_target(
            "//Modules/Lib2",
            …
        ),
    ],
)
[]
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

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,
xcschemes.top_level_anchor_target(
    …
    library_targets = [
        "//Modules/Lib1",
        xcschemes.library_target(
            "//Modules/Lib2",
            …
        ),
    ],
)
will be transformed into:
xcschemes.top_level_anchor_target(
    …
    library_targets = [
        xcschemes.library_target("//Modules/Lib1"),
        xcschemes.library_target(
            "//Modules/Lib2",
            …
        ),
    ],
)
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

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,
xcschemes.top_level_build_target(
    …
    library_targets = [
        "//Modules/Lib1",
        xcschemes.library_target(
            "//Modules/Lib2",
            …
        ),
    ],
)
will be transformed into:
xcschemes.top_level_build_target(
    …
    library_targets = [
        xcschemes.library_target("//Modules/Lib1"),
        xcschemes.library_target(
            "//Modules/Lib2",
            …
        ),
    ],
)
[]
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

Custom Xcode schemes (Legacy generation mode)

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

xcode_schemes.build_action(targets, pre_actions, post_actions)

Constructs a build action for an Xcode scheme.

PARAMETERS

Name Description Default Value
targets A sequence of elements that are either struct values as created by xcode_schemes.build_target, or a target label as a string value. none
pre_actions A sequence of struct values as created by xcode_schemes.pre_action. []
post_actions A sequence of struct values as created by xcode_schemes.post_action. []

RETURNS

A struct representing a build action.

xcode_schemes.build_for

xcode_schemes.build_for(running, testing, profiling, archiving, analyzing)

Construct a struct representing the settings that dictate when Xcode will build a target.

PARAMETERS

Name Description Default Value
running Optional. A bool specifying whether to build for the running phase. None
testing Optional. A bool specifying whether to build for the testing phase. None
profiling Optional. A bool specifying whether to build for the profiling phase. None
archiving Optional. A bool specifying whether to build for the archiving phase. None
analyzing Optional. A bool specifying whether to build for the analyzing phase. None

RETURNS

A struct.

xcode_schemes.build_target

xcode_schemes.build_target(label, build_for)

Constructs a build target for an Xcode scheme's build action.

PARAMETERS

Name Description Default Value
label A target label as a string value. none
build_for Optional. The settings that dictate when Xcode will build the target. It is a value returned by xcode_schemes.build_for. None

RETURNS

A struct representing a build target.

xcode_schemes.diagnostics

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

xcode_schemes.launch_action(target, args, build_configuration, diagnostics, env, working_directory)

Constructs a launch action for an Xcode scheme.

PARAMETERS

Name Description Default Value
target A target label as a string value. none
args Optional. A list of string arguments that should be passed to the target when executed. None
build_configuration Optional. The name of the Xcode configuration to use for this action.

If not set, then the configuration determined by xcodeproj.default_xcode_configuration will be used.
None
diagnostics Optional. A value returned by xcode_schemes.diagnostics. None
env Optional. A dict of string values that will be set as environment variables when the target is executed. None
working_directory Optional. A string that will be set as the custom working directory in the Xcode scheme's launch action. Relative paths will be relative to the value of target's BUILT_PRODUCTS_DIR, which is unique to it. None

RETURNS

A struct representing a launch action.

xcode_schemes.pre_post_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

Name Description Default Value
name Title of the script. "Run Script"
script The script text. none
expand_variables_based_on Optional. The label of the target that environment variables will expand based on. none

RETURNS

A struct representing a scheme's step pre or post action.

xcode_schemes.profile_action

xcode_schemes.profile_action(target, args, build_configuration, env, working_directory)

Constructs a profile action for an Xcode scheme.

PARAMETERS

Name Description Default Value
target A target label as a string value. none
args Optional. A list of string arguments that should be passed to the target when executed.

If both this and env are None (not just empty), then the launch action's arguments will be inherited.
None
build_configuration Optional. The name of the Xcode configuration to use for this action.

If not set, then the configuration determined by xcodeproj.default_xcode_configuration will be used.
None
env Optional. A dict of string values that will be set as environment variables when the target is executed.

If both this and args are None (not just empty), then the launch action's environment variables will be inherited.
None
working_directory Optional. A string that will be set as the custom working directory in the Xcode scheme's launch action.

Relative paths will be relative to the value of target's BUILT_PRODUCTS_DIR, which is unique to it.
None

RETURNS

A struct representing a profile action.

xcode_schemes.sanitizers

xcode_schemes.sanitizers(address, thread, undefined_behavior)

Constructs the scheme's sanitizers' default state. The state can also be modified in Xcode.

PARAMETERS

Name Description Default Value
address Optional. A boolean value representing whether the address sanitizer should be enabled or not. False
thread Optional. A boolean value representing whether the thread sanitizer should be enabled or not. False
undefined_behavior Optional. A boolean value representing whether the undefined behavior sanitizer should be enabled or not. False

xcode_schemes.scheme

xcode_schemes.scheme(name, build_action, launch_action, profile_action, test_action)

Returns a struct representing an Xcode scheme.

PARAMETERS

Name Description Default Value
name The user-visible name for the scheme as a string. none
build_action Optional. A value returned by xcode_schemes.build_action. None
launch_action Optional. A value returned by xcode_schemes.launch_action. None
profile_action Optional. A value returned by xcode_schemes.profile_action. None
test_action Optional. A value returned by xcode_schemes.test_action. None

RETURNS

A struct representing an Xcode scheme.

xcode_schemes.test_action

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

Name Description Default Value
targets A sequence of target labels as string values. none
args Optional. A list of string arguments that should be passed to the target when executed.

If both this and env are None (not just empty), then the launch action's arguments will be inherited.
None
build_configuration Optional. The name of the Xcode configuration to use for this action.

If not set, then the configuration determined by xcodeproj.default_xcode_configuration will be used.
None
diagnostics Optional. A value returned by xcode_schemes.diagnostics. None
env Optional. A dict of string values that will be set as environment variables when the target is executed.

If both this and args are None (not just empty), then the launch action's environment variables will be inherited.
None
expand_variables_based_on Optional. One of the specified test target labels.

If no value is provided, one of the test targets will be selected. If no expansion context is desired, use the string value none.
None
pre_actions Optional. A sequence of struct values as created by xcode_schemes.pre_post_action. []
post_actions Optional. A sequence of struct values as created by xcode_schemes.pre_post_action. []

RETURNS

A struct representing a test action.

Xcode build settings

Rules that provide additional information to the xcodeproj rule, so that it can properly determine values for various Xcode build settings.

xcode_provisioning_profile

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

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

XcodeProjAutomaticTargetProcessingInfo(alternate_icons, app_icons, args, bundle_id, codesign_inputs,
                                       codesignopts, collect_uncategorized_files, deps, entitlements,
                                       env, exported_symbols_lists, extra_files, 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

Name Description
alternate_icons An attribute name (or None) to collect the application alternate icons.

This is only used when xcodeproj.generation_mode = "legacy" is set.
app_icons An attribute name (or None) to collect the application icons.
args A List (or None) representing the command line arguments that this target should execute or test with.
bundle_id An attribute name (or None) to collect the bundle id string from.
codesign_inputs An attribute name (or None) to collect the codesign_inputs list from.

This is only used when xcodeproj.generation_mode = "legacy" is set.
codesignopts An attribute name (or None) to collect the codesignopts list from.

This is only used when xcodeproj.generation_mode = "legacy" is set.
collect_uncategorized_files Whether to collect files from uncategorized attributes.
deps A sequence of attribute names to collect Targets from for deps-like attributes.
entitlements An attribute name (or None) to collect Files from for the entitlements-like attribute.
env A dict representing the environment variables that this target should execute or test with.
exported_symbols_lists A sequence of attribute names to collect Files from for the exported_symbols_lists-like attributes.

This is only used when xcodeproj.generation_mode = "legacy" is set.
extra_files A sequence of attribute names to collect Files from to include in the project, which don't fall under other categorized attributes.

This is only used when xcodeproj.generation_mode = "incremental" is set.
hdrs A sequence of attribute names to collect Files from for hdrs-like attributes.

This is only used when xcodeproj.generation_mode = "legacy" is set.
implementation_deps A sequence of attribute names to collect Targets from for implementation_deps-like attributes.
infoplists A sequence of attribute names to collect Files from for the infoplists-like attributes.

This is only used when xcodeproj.generation_mode = "legacy" is set.
is_supported Whether an Xcode target can be generated for this target. Even if this value is False, setting values for the other attributes can cause inputs to be collected and shown in the Xcode project.
is_top_level Whether this target is a "top-level" (e.g. bundled or executable) target.
label The effective Label to use for the target. This should generally be target.label, but in the case of skipped wrapper rules (e.g. *_unit_test targets), you might want to rename the target to the skipped target's label.

This is only used when xcodeproj.generation_mode = "incremental" is set.
launchdplists A sequence of attribute names to collect Files from for the launchdplists-like attributes.

This is only used when xcodeproj.generation_mode = "legacy" is set.
link_mnemonics A sequence of mnemonic (action) names to gather link parameters. The first action that matches any of the mnemonics is used.
non_arc_srcs A sequence of attribute names to collect Files from for non_arc_srcs-like attributes.
pch An attribute name (or None) to collect Files from for the pch-like attribute.

This is only used when xcodeproj.generation_mode = "legacy" is set.
provisioning_profile An attribute name (or None) to collect Files from for the provisioning_profile-like attribute.
should_generate If is_supported is True, this determines whether an Xcode target should be generated for this target.

This is only used when xcodeproj.generation_mode = "incremental" is set.
srcs A sequence of attribute names to collect Files from for srcs-like attributes.
target_type See XcodeProjInfo.target_type.
xcode_targets A dict mapping attribute names to target type strings (i.e. "resource" or "compile"). Only Xcode targets from the specified attributes with the specified target type are allowed to propagate.

XcodeProjInfo

XcodeProjInfo(args, compilation_providers, direct_dependencies, envs, extension_infoplists,
              focused_labels, 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

Name Description
args A depset of structs with id and arg fields. The id field is the target ID (see xcode_target.id) of the target and arg values for the target (if applicable).
compilation_providers A value from compilation_providers.{collect,merge}.
direct_dependencies A depset of target IDs (see xcode_target.id) that this target directly depends on.
envs A depset of structs with id and env fields. The id field is the target ID (see xcode_target.id) of the target and env values for the target (if applicable).
extension_infoplists A depset of structs with id and infoplist fields. The id field is the target ID (see xcode_target.id) of the application extension target. The infoplist field is a File for the Info.plist for the target.
focused_labels A depset of label strings of focused targets. This will include the current target (if focused) and any focused dependencies of the current target.

This is only set and used when xcodeproj.generation_mode = "incremental" is set.
focused_library_deps A depset of structs with id and label fields. The id field is the target ID (see xcode_target.id) of a focused library target. The label field is the string label of the same target.

This field represents the transitive focused library dependencies of the target. Top-level targets use this field to determine the value of top_level_focused_deps. They also reset this value.

This is only set and used when xcodeproj.generation_mode = "incremental" is set.
framework_product_mappings A depset of (linker_path, product_path) tuples. linker_path is the .framework/Executable path used when linking to a framework. product_path is the path to a built .framework product. In particular, product_path can have a fully fleshed out framework, including resources, while linker_path will most likely only have a symlink to a .dylib in it.

This is only set and used when xcodeproj.generation_mode = "incremental" is set.
hosted_targets A depset of structs with host and hosted fields. The host field is the target ID (see xcode_target.id) of the hosting target. The hosted field is the target ID of the hosted target.
inputs A value from input_files.collect/inputs_files.merge, that contains information related to all of the input Files for the project collected so far. It also includes information related to "extra files" that should be added to the Xcode project, but are not associated with any targets.
label The Label of the target.

This is only set and used when xcodeproj.generation_mode = "legacy" is set.
labels A depset of Labels for the target and its transitive dependencies.

This is only set and used when xcodeproj.generation_mode = "legacy" is set.
lldb_context A value from lldb_context.collect.
mergable_xcode_library_targets A depset of target IDs (see xcode_target.id). Each represents a target that can potentially merge into a top-level target (to be decided by the top-level target).

This is only set and used when xcodeproj.generation_mode = "legacy" is set.
mergeable_infos A depset of structss. Each contains information about a target that can potentially merge into a top-level target (to be decided by the top-level target).

This is only set and used when xcodeproj.generation_mode = "incremental" is set.
merged_target_ids A depset of tuples. The first element is the target ID (see xcode_target.id) of the target being merged into. The second element is a list of target IDs that have been merged into the target referenced by the first element.

This is only set and used when xcodeproj.generation_mode = "incremental" is set.
non_top_level_rule_kind If this target is not a top-level target, this is the value from ctx.rule.kind, otherwise it is None. Top-level targets are targets that are valid to be listed in the top_level_targets attribute of xcodeproj. In particular, this means that they aren't library targets, which when specified in top_level_targets cause duplicate mis-configured targets to be added to the project.
outputs A value from output_files.collect/output_files.merge, that contains information about the output files for this target and its transitive dependencies.
platforms A depset of apple_platforms that this target and its transitive dependencies are built for.

This is only set and used when xcodeproj.generation_mode = "incremental" is set.
potential_target_merges A depset of structs with src and dest fields. The src field is the id of the target that can be merged into the target with the id of the dest field.

This is only set and used when xcodeproj.generation_mode = "legacy" is set.
replacement_labels A depset of structs with id and label fields. The id field is the target ID (see xcode_target.id) of the target that have its label (and name) be replaced with the label in the label field.

This is only set and used when xcodeproj.generation_mode = "legacy" is set.
resource_bundle_ids A depset of tuples mapping target ID (see xcode_target.id) to bundle id.
swift_debug_settings A depset of swift_debug_settings Files, produced by pbxproj_partials.write_target_build_settings.

This is only set and used when xcodeproj.generation_mode = "incremental" is set.
target_output_groups A value from output_groups.collect/output_groups.merge, that contains information related to BwB mode output groups.

This is only set and used when xcodeproj.generation_mode = "incremental" is set.
target_type A string that categorizes the type of the current target. This will be one of "compile", "resources", or None. Even if this target doesn't produce an Xcode target, it can still have a non-None value for this field.
top_level_focused_deps A depset of structs with id, label, and deps fields. The id field is the target ID (see xcode_target.id) of a top-level target. The label field is the string label of the same target. The deps field is a tuple (used as a frozen sequence) of values as stored in focused_library_deps.

This field is used to allow custom schemes (see the xcschemes module) to include the correct versions of library targets.

This is only set and used when xcodeproj.generation_mode = "incremental" is set.
top_level_swift_debug_settings A depset of tuples of an LLDB context key and swift_debug_settings Files, produced by pbxproj_partials.write_target_build_settings. This will be an empty depset for non-top-level targets.

This is only set and used when xcodeproj.generation_mode = "incremental" is set.
transitive_dependencies A depset of target IDs (see xcode_target.id) that this target transitively depends on.
xcode_required_targets A depset of values from xcode_targets.make for targets that need to be in projects that have build_mode = "xcode". This means that they can't be unfocused in BwX mode, and if requested it will be ignored.

This is only set and used when xcodeproj.generation_mode = "legacy" is set.
xcode_target A value from xcode_targets.make if this target can produce an Xcode target.
xcode_targets A depset of values from xcode_targets.make, which potentially will become targets in the Xcode project.