TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/MobileNativeFoundation/rules_xcodeproj/llms.txt
Use this file to discover all available pages before exploring further.
xcodeproj rule (actually a macro wrapper around the underlying rule) is the primary entry point for generating an Xcode project from your Bazel workspace. Load it in your BUILD file with:
kwargs argument passes through globally available Bazel attributes such as visibility and features to the underlying rule. The project is written to disk when you run the generated runner target (e.g. bazel run //:xcodeproj).
Minimal example
Attributes
A unique name for this target. This is the label you run with
bazel run to generate the project. If project_name is not set, this value is also used as the .xcodeproj filename.A list of top-level targets to include in the generated project. Each entry can be:
- A plain label string (e.g.
":App") - A value returned by
top_level_target() - A value returned by
top_level_targets()
The name to use for the
.xcodeproj file. If not specified, the value of name is used.Default: None (uses name)The path to the
bazel binary or a wrapper script. Relative paths are resolved using the PATH environment variable set at project generation time. To reference a workspace-relative binary, prepend ./ (e.g. "./bazelw").Default: "bazel"A dict of environment variables to set when invoking
bazel_path. Use this for variables required by Bazel actions (e.g. JAVA_HOME, ANDROID_HOME) or by a wrapper bazel_path script.- If a value is
None, the variable is resolved from the environment at project generation time. - Values that reference environment variables are also resolved at generation time.
- To include a literal
$, escape it with two backslashes.
PATH is omitted it defaults to /bin:/usr/bin. If LANG is omitted it defaults to en_US.UTF-8.Default: {"LANG": "en_US.UTF-8", "PATH": "/bin:/usr/bin"}The basename of the Bazel configs used during project generation and Xcode builds. For example, setting this to
"projectx_xcodeproj" makes the following configs available in your .bazelrc:projectx_xcodeprojprojectx_xcodeproj_generatorprojectx_xcodeproj_indexbuildprojectx_xcodeproj_swiftuipreviews
"rules_xcodeproj"The name of the Xcode configuration to use when building, unless a custom scheme overrides it. If not set, the first configuration alphabetically is used. See
xcode_configurations to define available configurations.Default: NoneA list of extra files to add to the Xcode project navigator. These files are not associated with any particular target.Default:
[]A dict of extra files to add to the project, associated with a specific target. The key is a label string for the target and the value is a list of files. Files are only added when the associated target is focused.Default:
{}A list of target label strings. When specified, only these targets (plus the top-level targets) are included in the generated project. All other transitive dependencies behave as if they were in
unfocused_targets.Default: []A list of target label strings to explicitly exclude from the generated project. This overrides any matching entries in
focused_targets. Excluded targets are replaced with pre-built artifacts.Default: []The workspace-relative directory where the
.xcodeproj will be written. Defaults to the directory containing the BUILD file where xcodeproj is declared. Pass "" to write to the workspace root.Default: None (directory of the declaring BUILD file)The minimum Xcode version supported by the generated project, expressed as a dot-separated version string (e.g.
"14", "14.1", "15.0.1"). Higher values enable more features. Defaults to the Xcode version Bazel uses during generation.Default: NoneA shell script to run after each build inside Xcode (e.g.
"./post-build.sh" or "$SRCROOT/post-build.sh"). The script runs in Bazel’s execution root. Because it also runs during Index Build, add a guard like if [ "$ACTION" == "build" ]; then ... if that is undesirable.Default: NoneA shell script to run before each build inside Xcode (e.g.
"./pre-build.sh" or "$SRCROOT/pre-build.sh"). The script runs in Bazel’s execution root. Add a guard for $ACTION == "build" if you want to skip execution during Index Build.Default: NoneControls how Xcode schemes are automatically generated:
"auto"— generates a scheme for every buildable target when no custom schemes are provided; suppresses autogeneration when custom schemes exist."none"— never autogenerates schemes."all"— always generates a scheme for every buildable target, even when custom schemes are also provided.
"auto"A value returned by
xcschemes.autogeneration_config. Provides fine-grained configuration of autogenerated schemes (pre/post actions, test options, name exclusion patterns, etc.). Only meaningful when scheme_autogeneration_mode is not "none".Default: NoneControls how Xcode target names are generated:
"auto"— uses the product name when available and unambiguous; falls back to the target name, then the full label on collision."label"— always uses the full Bazel label as the Xcode target name.
"auto"A dict mapping Xcode configuration names to Bazel transition settings. For example:See the Bazel configuration documentation for details on transition settings dictionaries.Default:
{"Debug": {}}A list of values returned by
xcschemes.scheme. Works in conjunction with scheme_autogeneration_mode to define custom Xcode schemes.Default: []A value returned by
project_options(). Configures project-level settings such as indentation style, tab width, organization name, and development region.Default: NoneWhether to import the index stores produced by Index Build into Xcode’s index. Enabling this speeds up Xcode’s code intelligence but increases disk I/O. Disable it if the overhead outweighs the benefit for your project size.Default:
TrueA dict of environment variables applied only during project generation (i.e. when running the generator target with
bazel run). These values are not written into the .xcodeproj and do not affect subsequent Xcode builds. Behaves identically to bazel_env otherwise.Default: {}CPU attributes
The following attributes control the CPU architectures used when building targets for each platform and environment. Changing any of these values affects the Starlark transition hash for all transitive dependencies of the relevant targets, even if they do not target that platform.Value passed to
--ios_multi_cpus for targets built with the "device" environment.Default: "arm64"Value passed to
--ios_multi_cpus for targets built with the "simulator" environment. When unset, defaults to sim_arm64 on Apple Silicon or x86_64 on Intel.Default: NoneValue passed to
--tvos_cpus for targets built with the "device" environment.Default: "arm64"Value passed to
--tvos_cpus for targets built with the "simulator" environment. Defaults to sim_arm64 on Apple Silicon or x86_64 on Intel when unset.Default: NoneValue passed to
--visionos_cpus for targets built with the "device" environment.Default: "arm64"Value passed to
--visionos_cpus for targets built with the "simulator" environment.Default: "sim_arm64"Value passed to
--watchos_cpus for targets built with the "device" environment.Default: "arm64_32"Value passed to
--watchos_cpus for targets built with the "simulator" environment. Defaults to arm64 on Apple Silicon or x86_64 on Intel when unset.Default: None