Skip to main content

Documentation 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.

rules_xcodeproj exposes two Starlark providers that rules can return to control how the xcodeproj aspect processes their targets. These are the primary extension points for integrating custom Bazel rules with the Xcode project generator.
Both providers currently have an unstable API and may change in future releases. If you are using either provider, please open an issue so the team can prioritize stabilizing it.

XcodeProjAutomaticTargetProcessingInfo

load("@rules_xcodeproj//xcodeproj:defs.bzl", "XcodeProjAutomaticTargetProcessingInfo")
XcodeProjAutomaticTargetProcessingInfo is returned by a target to control how the xcodeproj aspect’s automatic target processing discovers source files, resources, headers, and nested Xcode targets. This is the primary extension point for adapting custom rules to work with rules_xcodeproj. When a target returns this provider, the aspect uses it instead of its built-in heuristics to determine how the target should appear in the generated Xcode project.

Fields

srcs
sequence[string]
A sequence of attribute names to collect Files from for srcs-like attributes. The files found under these attributes are treated as source files in the Xcode target.
non_arc_srcs
sequence[string]
A sequence of attribute names to collect Files from for non_arc_srcs-like attributes. Used for Objective-C source files that should be compiled without Automatic Reference Counting (ARC).
extra_files
sequence[string]
A sequence of attribute names to collect Files from to include in the project that don’t fall under other categorized attributes. Use this for headers, module maps, plists, and other non-compiled inputs you want visible in Xcode.
deps
sequence[string]
A sequence of attribute names to collect Targets from for deps-like attributes. The aspect traverses these attributes to discover transitive dependencies.
implementation_deps
sequence[string]
A sequence of attribute names to collect Targets from for implementation_deps-like attributes. These are treated as private dependencies that are not exposed to dependents.
xcode_targets
dict[string, list[string]]
A dict mapping attribute names to a list of target type strings (e.g. "compile" or None). Only Xcode targets from the specified attributes with a matching target type are allowed to propagate into the generated project. Use this to control which nested targets become their own Xcode targets.
target_type
string | None
Categorizes the type of target. Use "compile" for targets that produce compiled output (libraries, binaries, bundles). Set to None to prevent the target from producing an Xcode target, while still allowing its inputs to be collected if other fields are set.
is_supported
Boolean
Whether an Xcode target can be generated for this target. Even if False, setting values for the other attributes can still cause inputs to be collected and shown in the Xcode project.
is_top_level
Boolean
Whether this target is a top-level (e.g. bundled app or executable) target. Top-level targets can be listed directly in the top_level_targets attribute of xcodeproj.
args
list[string] | None
A list representing the command-line arguments that this target should execute or test with. Only meaningful for executable or test targets.
env
dict[string, string] | None
A dict representing the environment variables that this target should execute or test with.
label
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 wrapped target’s label.
bundle_id
string | None
An attribute name (or None) to collect the bundle ID string from.
app_icons
string | None
An attribute name (or None) to collect application icons from.
entitlements
string | None
An attribute name (or None) to collect Files from for the entitlements-like attribute.
provisioning_profile
string | None
An attribute name (or None) to collect Files from for the provisioning_profile-like attribute.
collect_uncategorized_files
Boolean
Whether to collect files from uncategorized attributes and include them in the project.
is_mixed_language
Boolean
Whether this target is a mixed-language target (i.e. contains both Swift and Objective-C sources).
is_header_only_library
Boolean
Whether this target contains no source files and only exposes headers.
A sequence of mnemonic (action) names used to gather link parameters. The first action that matches any of the mnemonics is used.

Example

The following shows a custom rule returning XcodeProjAutomaticTargetProcessingInfo to tell the aspect how to process it:
load(
    "@rules_xcodeproj//xcodeproj:defs.bzl",
    "XcodeProjAutomaticTargetProcessingInfo",
)

def _my_library_impl(ctx):
    # ... rule implementation ...
    return [
        # ... other providers ...
        XcodeProjAutomaticTargetProcessingInfo(
            srcs = ["srcs"],
            extra_files = ["hdrs"],
            deps = ["deps"],
            target_type = "compile",
            is_supported = True,
        ),
    ]
For guidance on creating custom Xcode schemes for your targets, see the Custom Schemes guide.

XcodeProjInfo

load("@rules_xcodeproj//xcodeproj:defs.bzl", "XcodeProjInfo")
XcodeProjInfo is returned by targets to provide rich metadata to the xcodeproj aspect about how a target should be represented in the generated project. It carries depsets of structured data — compiled outputs, dependencies, LLDB context, output groups, and more — that the aspect accumulates as it traverses the build graph.
XcodeProjInfo is primarily an informational provider propagated by the aspect itself. For most custom rule use cases, returning XcodeProjAutomaticTargetProcessingInfo is the correct extension point. Use XcodeProjInfo only when you need full control over how a target and its dependencies are processed.

Fields

label
Label
The Label of the target.
target_type
string | None
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.
xcode_target
struct | None
A value from xcode_targets.make if this target can produce an Xcode target.
xcode_targets
depset
A depset of values from xcode_targets.make, which potentially will become targets in the Xcode project.
inputs
struct
A value from input_files.collect/input_files.merge that contains information related to all input Files for the project collected so far. It also includes information about “extra files” that should be added to the Xcode project but are not associated with any targets.
outputs
struct
A value from output_files.collect/output_files.merge that contains information about the output files for this target and its transitive dependencies.
direct_dependencies
depset[string]
A depset of target IDs that this target directly depends on.
transitive_dependencies
depset[string]
A depset of target IDs that this target transitively depends on.
focused_labels
depset[string]
A depset of label strings of focused targets. This will include the current target (if focused) and any focused dependencies of the current target.
focused_library_deps
depset[struct]
A depset of structs with id and label fields representing the transitive focused library dependencies of the target. Top-level targets use this field to determine the value of top_level_focused_deps.
top_level_focused_deps
depset[struct]
A depset of structs with id, label, and deps fields. Used to allow custom schemes (see the xcschemes module) to include the correct versions of library targets.
args
depset[struct]
A depset of structs with id and arg fields containing command-line argument values per target ID.
envs
depset[struct]
A depset of structs with id and env fields containing environment variable values per target ID.
extension_infoplists
depset[struct]
A depset of structs with id and infoplist fields. The id is the target ID of the application extension, and infoplist is its Info.plist File.
hosted_targets
depset[struct]
A depset of structs with host and hosted fields, mapping host target IDs to their hosted target IDs (e.g. app extensions hosted by an app).
platforms
depset[struct]
A depset of apple_platforms that this target and its transitive dependencies are built for.
resource_bundle_ids
depset[tuple]
A depset of tuples mapping target ID to bundle ID for resource bundle targets.
compilation_providers
struct
A value from compilation_providers.{collect,merge} carrying compiler flag and search path information.
lldb_context
struct
A value from lldb_context.collect used to configure LLDB for debugging targets built with Bazel.
swift_debug_settings
depset[File]
A depset of Swift debug settings Files produced by pbxproj_partials.write_target_build_settings.
top_level_swift_debug_settings
depset[tuple]
A depset of tuples of an LLDB context key and Swift debug settings Files. Empty for non-top-level targets.
target_output_groups
struct
A value from output_groups.collect/output_groups.merge containing information related to Build with Bazel (BwB) mode output groups.
mergable_xcode_library_targets
depset[string]
A depset of target IDs, each representing a target that can potentially be merged into a top-level target (determined by the top-level target).
mergeable_infos
depset[struct]
A depset of structs containing information about targets that can potentially be merged into a top-level target.
merged_target_ids
depset[tuple]
A depset of tuples where the first element is the target ID being merged into and the second is a list of target IDs that have been merged into it.
framework_product_mappings
depset[tuple]
A depset of (linker_path, product_path) tuples mapping linker-visible framework paths to their full built product paths.
non_top_level_rule_kind
string | None
If this target is not a top-level target, this is the value from ctx.rule.kind; otherwise None. Used to prevent library targets from being mistakenly listed as top-level targets.

Build docs developers (and LLMs) love