Build rules for iOS

Rules

ios_application

Builds and bundles an iOS Application.

Example usage (generated)

load("@rules_apple//apple:ios.doc.bzl", "ios_application")

ios_application(
    # A unique name for this target.
    name = "",
    # The bundle ID (reverse-DNS path followed by app name) for this target.
    bundle_id = "",
    # A list of device families supported by this extension
    families = [],
    # A list of .plist files that will be merged to form the Info.plist for this target
    infoplists = [],
    # A required string indicating the minimum OS version supported by the target, represented as a
    minimum_os_version = "",
)

name

A unique name for this target.

alternate_icons

Files that comprise the alternate app icons for the application. Each file must have a containing directory named after the alternate icon identifier.

app_clips

A list of iOS app clips to include in the final application bundle.

app_icons

Files that comprise the app icons for the application. Each file must have a containing directory named *..xcassets/*..appiconset and there may be only one such ..appiconset directory in the list.

binary_type

This attribute is public as an implementation detail while we migrate the architecture of the rules. Do not change its value.

bundle_id

The bundle ID (reverse-DNS path followed by app name) for this target.

bundle_loader

This attribute is public as an implementation detail while we migrate the architecture of the rules. Do not change its value.

bundle_name

The desired name of the bundle (without the extension). If this attribute is not set, then the name of the target will be used instead.

codesign_inputs

A list of dependencies targets that provide inputs that will be used by codesign (referenced with codesignopts).

codesignopts

A list of strings representing extra flags that should be passed to codesign.

deps

A list of dependencies targets that will be linked into this target's binary. Any resources, such as asset catalogs, that are referenced by those targets will also be transitively included in the final bundle.

dylibs

This attribute is public as an implementation detail while we migrate the architecture of the rules. Do not change its value.

entitlements

The entitlements file required for device builds of this target. If absent, the default entitlements from the provisioning profile will be used.

The following variables are substituted in the entitlements file: $(CFBundleIdentifier) with the bundle ID of the application and $(AppIdentifierPrefix) with the value of the ApplicationIdentifierPrefix key from the target's provisioning profile.

entitlements_validation

An entitlements_validation_mode to control the validation of the requested entitlements against the provisioning profile to ensure they are supported.

executable_name

The desired name of the executable, if the bundle has an executable. If this attribute is not set, then the name of the bundle_name attribute will be used if it is set; if not, then the name of the target will be used instead.

exported_symbols_lists

A list of targets containing exported symbols lists files for the linker to control symbol resolution.

Each file is expected to have a list of global symbol names that will remain as global symbols in the compiled binary owned by this framework. All other global symbols will be treated as if they were marked as __private_extern__ (aka visibility=hidden) and will not be global in the output file.

See the man page documentation for ld(1) on macOS for more details.

extensions

A list of iOS application extensions to include in the final application bundle.

families

A list of device families supported by this extension. Valid values are iphone and ipad; at least one must be specified.

frameworks

A list of framework targets (see ios_framework) that this target depends on.

include_symbols_in_bundle

If true and --output_groups=+dsyms is specified, generates $UUID.symbols files from all {binary: .dSYM, ...} pairs for the application and its dependencies, then packages them under the Symbols/ directory in the final application bundle.

infoplists

A list of .plist files that will be merged to form the Info.plist for this target. At least one file must be specified. Please see Info.plist Handling for what is supported.

ipa_post_processor

A tool that edits this target's archive after it is assembled but before it is signed. The tool is invoked with a single command-line argument that denotes the path to a directory containing the unzipped contents of the archive; this target's bundle will be the directory's only contents.

Any changes made by the tool must be made in this directory, and the tool's execution must be hermetic given these inputs to ensure that the result can be safely cached.

launch_images

Files that comprise the launch images for the application. Each file must have a containing directory named *.xcassets/*.launchimage and there may be only one such .launchimage directory in the list.

launch_storyboard

The .storyboard or .xib file that should be used as the launch screen for the application. The provided file will be compiled into the appropriate format (.storyboardc or .nib) and placed in the root of the final bundle. The generated file will also be registered in the bundle's Info.plist under the key UILaunchStoryboardName.

linkopts

A list of strings representing extra flags that should be passed to the linker.

minimum_os_version

A required string indicating the minimum OS version supported by the target, represented as a dotted version number (for example, "9.0").

platform_type

provisioning_profile

The provisioning profile (.mobileprovision file) to use when creating the bundle. This value is optional for simulator builds as the simulator doesn't fully enforce entitlements, but is required for device builds.

resources

A list of resources or files bundled with the bundle. The resources will be stored in the appropriate resources location within the bundle.

sdk_frameworks

Names of SDK frameworks to link with (e.g., AddressBook, QuartzCore). UIKit and Foundation are always included, even if this attribute is provided and does not list them.

This attribute is discouraged; in general, targets should list system framework dependencies in the library targets where that framework is used, not in the top-level bundle.

settings_bundle

A resource bundle (e.g. apple_bundle_import) target that contains the files that make up the application's settings bundle. These files will be copied into the root of the final application bundle in a directory named Settings.bundle.

stamp

Enable link stamping. Whether to encode build information into the binary. Possible values:

  • stamp = 1: Stamp the build information into the binary. Stamped binaries are only rebuilt when their dependencies change. Use this if there are tests that depend on the build information.
  • stamp = 0: Always replace build information by constant values. This gives good build result caching.
  • stamp = -1: Embedding of build information is controlled by the --[no]stamp flag.

strings

A list of .strings files, often localizable. These files are converted to binary plists (if they are not already) and placed in the root of the final bundle, unless a file's immediate containing directory is named *.lproj, in which case it will be placed under a directory with the same name in the bundle.

version

An apple_bundle_version target that represents the version for this target. See apple_bundle_version.

watch_application

A watchos_application target that represents an Apple Watch application that should be embedded in the application bundle.


ios_build_test

Test rule to check that the given library targets (Swift, Objective-C, C++) build for iOS.

Typical usage:

ios_build_test(
    name = "my_build_test",
    minimum_os_version = "12.0",
    targets = [
        "//some/package:my_library",
    ],
)

Example usage (generated)

load("@rules_apple//apple:ios.doc.bzl", "ios_build_test")

ios_build_test(
    # A unique name for this target.
    name = "",
)

name

A unique name for this target.

minimum_os_version

A required string indicating the minimum OS version that will be used as the deployment target when building the targets, represented as a dotted version number (for example, "9.0").

platform_type

targets

The targets to check for successful build.


ios_extension

Builds and bundles an iOS Application Extension.

Most iOS app extensions use a plug-in-based architecture where the executable's entry point is provided by a system framework. However, iOS 14 introduced Widget Extensions that use a traditional main entry point (typically expressed through Swift's @main attribute). If you are building a Widget Extension, you must set provides_main = True to indicate that your code provides the entry point so that Bazel doesn't direct the linker to use the system framework's entry point instead.

Example usage (generated)

load("@rules_apple//apple:ios.doc.bzl", "ios_extension")

ios_extension(
    # A unique name for this target.
    name = "",
    # The bundle ID (reverse-DNS path followed by app name) for this target.
    bundle_id = "",
    # A list of device families supported by this extension
    families = [],
    # A list of .plist files that will be merged to form the Info.plist for this target
    infoplists = [],
    # A required string indicating the minimum OS version supported by the target, represented as a
    minimum_os_version = "",
)

name

A unique name for this target.

app_icons

Files that comprise the app icons for the application. Each file must have a containing directory named *..xcassets/*..appiconset and there may be only one such ..appiconset directory in the list.

binary_type

This attribute is public as an implementation detail while we migrate the architecture of the rules. Do not change its value.

bundle_id

The bundle ID (reverse-DNS path followed by app name) for this target.

bundle_loader

This attribute is public as an implementation detail while we migrate the architecture of the rules. Do not change its value.

bundle_name

The desired name of the bundle (without the extension). If this attribute is not set, then the name of the target will be used instead.

codesign_inputs

A list of dependencies targets that provide inputs that will be used by codesign (referenced with codesignopts).

codesignopts

A list of strings representing extra flags that should be passed to codesign.

deps

A list of dependencies targets that will be linked into this target's binary. Any resources, such as asset catalogs, that are referenced by those targets will also be transitively included in the final bundle.

dylibs

This attribute is public as an implementation detail while we migrate the architecture of the rules. Do not change its value.

entitlements

The entitlements file required for device builds of this target. If absent, the default entitlements from the provisioning profile will be used.

The following variables are substituted in the entitlements file: $(CFBundleIdentifier) with the bundle ID of the application and $(AppIdentifierPrefix) with the value of the ApplicationIdentifierPrefix key from the target's provisioning profile.

entitlements_validation

An entitlements_validation_mode to control the validation of the requested entitlements against the provisioning profile to ensure they are supported.

executable_name

The desired name of the executable, if the bundle has an executable. If this attribute is not set, then the name of the bundle_name attribute will be used if it is set; if not, then the name of the target will be used instead.

exported_symbols_lists

A list of targets containing exported symbols lists files for the linker to control symbol resolution.

Each file is expected to have a list of global symbol names that will remain as global symbols in the compiled binary owned by this framework. All other global symbols will be treated as if they were marked as __private_extern__ (aka visibility=hidden) and will not be global in the output file.

See the man page documentation for ld(1) on macOS for more details.

families

A list of device families supported by this extension. Valid values are iphone and ipad; at least one must be specified.

frameworks

A list of framework targets (see ios_framework) that this target depends on.

infoplists

A list of .plist files that will be merged to form the Info.plist for this target. At least one file must be specified. Please see Info.plist Handling for what is supported.

ipa_post_processor

A tool that edits this target's archive after it is assembled but before it is signed. The tool is invoked with a single command-line argument that denotes the path to a directory containing the unzipped contents of the archive; this target's bundle will be the directory's only contents.

Any changes made by the tool must be made in this directory, and the tool's execution must be hermetic given these inputs to ensure that the result can be safely cached.

linkopts

A list of strings representing extra flags that should be passed to the linker.

minimum_os_version

A required string indicating the minimum OS version supported by the target, represented as a dotted version number (for example, "9.0").

platform_type

provisioning_profile

The provisioning profile (.mobileprovision file) to use when creating the bundle. This value is optional for simulator builds as the simulator doesn't fully enforce entitlements, but is required for device builds.

resources

A list of resources or files bundled with the bundle. The resources will be stored in the appropriate resources location within the bundle.

sdk_frameworks

Names of SDK frameworks to link with (e.g., AddressBook, QuartzCore). UIKit and Foundation are always included, even if this attribute is provided and does not list them.

This attribute is discouraged; in general, targets should list system framework dependencies in the library targets where that framework is used, not in the top-level bundle.

stamp

Enable link stamping. Whether to encode build information into the binary. Possible values:

  • stamp = 1: Stamp the build information into the binary. Stamped binaries are only rebuilt when their dependencies change. Use this if there are tests that depend on the build information.
  • stamp = 0: Always replace build information by constant values. This gives good build result caching.
  • stamp = -1: Embedding of build information is controlled by the --[no]stamp flag.

strings

A list of .strings files, often localizable. These files are converted to binary plists (if they are not already) and placed in the root of the final bundle, unless a file's immediate containing directory is named *.lproj, in which case it will be placed under a directory with the same name in the bundle.

version

An apple_bundle_version target that represents the version for this target. See apple_bundle_version.


ios_framework

Builds and bundles an iOS Dynamic Framework.

To use this framework for your app and extensions, list it in the frameworks attributes of those ios_application and/or ios_extension rules.

Example usage (generated)

load("@rules_apple//apple:ios.doc.bzl", "ios_framework")

ios_framework(
    # A unique name for this target.
    name = "",
    # The bundle ID (reverse-DNS path followed by app name) for this target.
    bundle_id = "",
    # A list of device families supported by this extension
    families = [],
    # A list of .plist files that will be merged to form the Info.plist for this target
    infoplists = [],
    # A required string indicating the minimum OS version supported by the target, represented as a
    minimum_os_version = "",
)

name

A unique name for this target.

binary_type

This attribute is public as an implementation detail while we migrate the architecture of the rules. Do not change its value.

bundle_id

The bundle ID (reverse-DNS path followed by app name) for this target.

bundle_loader

This attribute is public as an implementation detail while we migrate the architecture of the rules. Do not change its value.

bundle_name

The desired name of the bundle (without the extension). If this attribute is not set, then the name of the target will be used instead.

bundle_only

Avoid linking the dynamic framework, but still include it in the app. This is useful when you want to manually dlopen the framework at runtime.

codesign_inputs

A list of dependencies targets that provide inputs that will be used by codesign (referenced with codesignopts).

codesignopts

A list of strings representing extra flags that should be passed to codesign.

deps

A list of dependencies targets that will be linked into this target's binary. Any resources, such as asset catalogs, that are referenced by those targets will also be transitively included in the final bundle.

dylibs

This attribute is public as an implementation detail while we migrate the architecture of the rules. Do not change its value.

executable_name

The desired name of the executable, if the bundle has an executable. If this attribute is not set, then the name of the bundle_name attribute will be used if it is set; if not, then the name of the target will be used instead.

exported_symbols_lists

A list of targets containing exported symbols lists files for the linker to control symbol resolution.

Each file is expected to have a list of global symbol names that will remain as global symbols in the compiled binary owned by this framework. All other global symbols will be treated as if they were marked as __private_extern__ (aka visibility=hidden) and will not be global in the output file.

See the man page documentation for ld(1) on macOS for more details.

extension_safe

If true, compiles and links this framework with -application-extension, restricting the binary to use only extension-safe APIs.

families

A list of device families supported by this extension. Valid values are iphone and ipad; at least one must be specified.

frameworks

A list of framework targets (see ios_framework) that this target depends on.

hdrs

infoplists

A list of .plist files that will be merged to form the Info.plist for this target. At least one file must be specified. Please see Info.plist Handling for what is supported.

ipa_post_processor

A tool that edits this target's archive after it is assembled but before it is signed. The tool is invoked with a single command-line argument that denotes the path to a directory containing the unzipped contents of the archive; this target's bundle will be the directory's only contents.

Any changes made by the tool must be made in this directory, and the tool's execution must be hermetic given these inputs to ensure that the result can be safely cached.

linkopts

A list of strings representing extra flags that should be passed to the linker.

minimum_os_version

A required string indicating the minimum OS version supported by the target, represented as a dotted version number (for example, "9.0").

platform_type

provisioning_profile

The provisioning profile (.mobileprovision file) to use when creating the bundle. This value is optional for simulator builds as the simulator doesn't fully enforce entitlements, but is required for device builds.

resources

A list of resources or files bundled with the bundle. The resources will be stored in the appropriate resources location within the bundle.

stamp

Enable link stamping. Whether to encode build information into the binary. Possible values:

  • stamp = 1: Stamp the build information into the binary. Stamped binaries are only rebuilt when their dependencies change. Use this if there are tests that depend on the build information.
  • stamp = 0: Always replace build information by constant values. This gives good build result caching.
  • stamp = -1: Embedding of build information is controlled by the --[no]stamp flag.

strings

A list of .strings files, often localizable. These files are converted to binary plists (if they are not already) and placed in the root of the final bundle, unless a file's immediate containing directory is named *.lproj, in which case it will be placed under a directory with the same name in the bundle.

version

An apple_bundle_version target that represents the version for this target. See apple_bundle_version.


ios_imessage_application

Builds and bundles an iOS iMessage Application.

iOS iMessage applications do not have any dependencies, as it works mostly as a wrapper for either an iOS iMessage extension or a Sticker Pack extension.

Example usage (generated)

load("@rules_apple//apple:ios.doc.bzl", "ios_imessage_application")

ios_imessage_application(
    # A unique name for this target.
    name = "",
    # The bundle ID (reverse-DNS path followed by app name) for this target.
    bundle_id = "",
    # Single label referencing either an ios_imessage_extension or ios_sticker_pack_extension target
    extension = "",
    # A list of device families supported by this extension
    families = [],
    # A list of .plist files that will be merged to form the Info.plist for this target
    infoplists = [],
    # A required string indicating the minimum OS version supported by the target, represented as a
    minimum_os_version = "",
)

name

A unique name for this target.

app_icons

Files that comprise the app icons for the application. Each file must have a containing directory named *..xcassets/*..appiconset and there may be only one such ..appiconset directory in the list.

bundle_id

The bundle ID (reverse-DNS path followed by app name) for this target.

bundle_name

The desired name of the bundle (without the extension). If this attribute is not set, then the name of the target will be used instead.

entitlements

The entitlements file required for device builds of this target. If absent, the default entitlements from the provisioning profile will be used.

The following variables are substituted in the entitlements file: $(CFBundleIdentifier) with the bundle ID of the application and $(AppIdentifierPrefix) with the value of the ApplicationIdentifierPrefix key from the target's provisioning profile.

entitlements_validation

An entitlements_validation_mode to control the validation of the requested entitlements against the provisioning profile to ensure they are supported.

executable_name

The desired name of the executable, if the bundle has an executable. If this attribute is not set, then the name of the bundle_name attribute will be used if it is set; if not, then the name of the target will be used instead.

extension

Single label referencing either an ios_imessage_extension or ios_sticker_pack_extension target. Required.

families

A list of device families supported by this extension. Valid values are iphone and ipad; at least one must be specified.

infoplists

A list of .plist files that will be merged to form the Info.plist for this target. At least one file must be specified. Please see Info.plist Handling for what is supported.

ipa_post_processor

A tool that edits this target's archive after it is assembled but before it is signed. The tool is invoked with a single command-line argument that denotes the path to a directory containing the unzipped contents of the archive; this target's bundle will be the directory's only contents.

Any changes made by the tool must be made in this directory, and the tool's execution must be hermetic given these inputs to ensure that the result can be safely cached.

minimum_os_version

A required string indicating the minimum OS version supported by the target, represented as a dotted version number (for example, "9.0").

platform_type

provisioning_profile

The provisioning profile (.mobileprovision file) to use when creating the bundle. This value is optional for simulator builds as the simulator doesn't fully enforce entitlements, but is required for device builds.

resources

A list of resources or files bundled with the bundle. The resources will be stored in the appropriate resources location within the bundle.

strings

A list of .strings files, often localizable. These files are converted to binary plists (if they are not already) and placed in the root of the final bundle, unless a file's immediate containing directory is named *.lproj, in which case it will be placed under a directory with the same name in the bundle.

version

An apple_bundle_version target that represents the version for this target. See apple_bundle_version.


ios_imessage_extension

Builds and bundles an iOS iMessage Extension.

Example usage (generated)

load("@rules_apple//apple:ios.doc.bzl", "ios_imessage_extension")

ios_imessage_extension(
    # A unique name for this target.
    name = "",
    # The bundle ID (reverse-DNS path followed by app name) for this target.
    bundle_id = "",
    # A list of device families supported by this extension
    families = [],
    # A list of .plist files that will be merged to form the Info.plist for this target
    infoplists = [],
    # A required string indicating the minimum OS version supported by the target, represented as a
    minimum_os_version = "",
)

name

A unique name for this target.

app_icons

Files that comprise the app icons for the application. Each file must have a containing directory named *..xcassets/*..stickersiconset and there may be only one such ..stickersiconset directory in the list.

binary_type

This attribute is public as an implementation detail while we migrate the architecture of the rules. Do not change its value.

bundle_id

The bundle ID (reverse-DNS path followed by app name) for this target.

bundle_loader

This attribute is public as an implementation detail while we migrate the architecture of the rules. Do not change its value.

bundle_name

The desired name of the bundle (without the extension). If this attribute is not set, then the name of the target will be used instead.

codesign_inputs

A list of dependencies targets that provide inputs that will be used by codesign (referenced with codesignopts).

codesignopts

A list of strings representing extra flags that should be passed to codesign.

deps

A list of dependencies targets that will be linked into this target's binary. Any resources, such as asset catalogs, that are referenced by those targets will also be transitively included in the final bundle.

dylibs

This attribute is public as an implementation detail while we migrate the architecture of the rules. Do not change its value.

entitlements

The entitlements file required for device builds of this target. If absent, the default entitlements from the provisioning profile will be used.

The following variables are substituted in the entitlements file: $(CFBundleIdentifier) with the bundle ID of the application and $(AppIdentifierPrefix) with the value of the ApplicationIdentifierPrefix key from the target's provisioning profile.

entitlements_validation

An entitlements_validation_mode to control the validation of the requested entitlements against the provisioning profile to ensure they are supported.

executable_name

The desired name of the executable, if the bundle has an executable. If this attribute is not set, then the name of the bundle_name attribute will be used if it is set; if not, then the name of the target will be used instead.

exported_symbols_lists

A list of targets containing exported symbols lists files for the linker to control symbol resolution.

Each file is expected to have a list of global symbol names that will remain as global symbols in the compiled binary owned by this framework. All other global symbols will be treated as if they were marked as __private_extern__ (aka visibility=hidden) and will not be global in the output file.

See the man page documentation for ld(1) on macOS for more details.

families

A list of device families supported by this extension. Valid values are iphone and ipad; at least one must be specified.

frameworks

A list of framework targets (see ios_framework) that this target depends on.

infoplists

A list of .plist files that will be merged to form the Info.plist for this target. At least one file must be specified. Please see Info.plist Handling for what is supported.

ipa_post_processor

A tool that edits this target's archive after it is assembled but before it is signed. The tool is invoked with a single command-line argument that denotes the path to a directory containing the unzipped contents of the archive; this target's bundle will be the directory's only contents.

Any changes made by the tool must be made in this directory, and the tool's execution must be hermetic given these inputs to ensure that the result can be safely cached.

linkopts

A list of strings representing extra flags that should be passed to the linker.

minimum_os_version

A required string indicating the minimum OS version supported by the target, represented as a dotted version number (for example, "9.0").

platform_type

provisioning_profile

The provisioning profile (.mobileprovision file) to use when creating the bundle. This value is optional for simulator builds as the simulator doesn't fully enforce entitlements, but is required for device builds.

resources

A list of resources or files bundled with the bundle. The resources will be stored in the appropriate resources location within the bundle.

stamp

Enable link stamping. Whether to encode build information into the binary. Possible values:

  • stamp = 1: Stamp the build information into the binary. Stamped binaries are only rebuilt when their dependencies change. Use this if there are tests that depend on the build information.
  • stamp = 0: Always replace build information by constant values. This gives good build result caching.
  • stamp = -1: Embedding of build information is controlled by the --[no]stamp flag.

strings

A list of .strings files, often localizable. These files are converted to binary plists (if they are not already) and placed in the root of the final bundle, unless a file's immediate containing directory is named *.lproj, in which case it will be placed under a directory with the same name in the bundle.

version

An apple_bundle_version target that represents the version for this target. See apple_bundle_version.


ios_static_framework

Builds and bundles an iOS static framework for third-party distribution.

A static framework is bundled like a dynamic framework except that the embedded binary is a static library rather than a dynamic library. It is intended to create distributable static SDKs or artifacts that can be easily imported into other Xcode projects; it is specifically not intended to be used as a dependency of other Bazel targets. For that use case, use the corresponding objc_library targets directly.

Unlike other iOS bundles, the fat binary in an ios_static_framework may simultaneously contain simulator and device architectures (that is, you can build a single framework artifact that works for all architectures by specifying --ios_multi_cpus=i386,x86_64,armv7,arm64 when you build).

ios_static_framework supports Swift, but there are some constraints:

  • ios_static_framework with Swift only works with Xcode 11 and above, since the required Swift functionality for module compatibility is available in Swift 5.1.
  • ios_static_framework only supports a single direct swift_library target that does not depend transitively on any other swift_library targets. The Swift compiler expects a framework to contain a single Swift module, and each swift_library target is its own module by definition.
  • ios_static_framework does not support mixed Objective-C and Swift public interfaces. This means that the umbrella_header and hdrs attributes are unavailable when using swift_library dependencies. You are allowed to depend on objc_library from the main swift_library dependency, but note that only the swift_library's public interface will be available to users of the static framework.

When using Swift, the ios_static_framework bundles swiftinterface and swiftdocs file for each of the required architectures. It also bundles an umbrella header which is the header generated by the single swift_library target. Finally, it also bundles a module.modulemap file pointing to the umbrella header for Objetive-C module compatibility. This umbrella header and modulemap can be skipped by disabling the swift.no_generated_header feature ( i.e. --features=-swift.no_generated_header).

Example usage (generated)

load("@rules_apple//apple:ios.doc.bzl", "ios_static_framework")

ios_static_framework(
    # A unique name for this target.
    name = "",
    # A required string indicating the minimum OS version supported by the target, represented as a
    minimum_os_version = "",
)

name

A unique name for this target.

avoid_deps

A list of library targets on which this framework depends in order to compile, but the transitive closure of which will not be linked into the framework's binary.

binary_type

This attribute is public as an implementation detail while we migrate the architecture of the rules. Do not change its value.

bundle_loader

This attribute is public as an implementation detail while we migrate the architecture of the rules. Do not change its value.

bundle_name

The desired name of the bundle (without the extension). If this attribute is not set, then the name of the target will be used instead.

codesign_inputs

A list of dependencies targets that provide inputs that will be used by codesign (referenced with codesignopts).

codesignopts

A list of strings representing extra flags that should be passed to codesign.

deps

A list of dependencies targets that will be linked into this target's binary. Any resources, such as asset catalogs, that are referenced by those targets will also be transitively included in the final bundle.

dylibs

This attribute is public as an implementation detail while we migrate the architecture of the rules. Do not change its value.

exclude_resources

Indicates whether resources should be excluded from the bundle. This can be used to avoid unnecessarily bundling resources if the static framework is being distributed in a different fashion, such as a Cocoapod.

executable_name

The desired name of the executable, if the bundle has an executable. If this attribute is not set, then the name of the bundle_name attribute will be used if it is set; if not, then the name of the target will be used instead.

exported_symbols_lists

A list of targets containing exported symbols lists files for the linker to control symbol resolution.

Each file is expected to have a list of global symbol names that will remain as global symbols in the compiled binary owned by this framework. All other global symbols will be treated as if they were marked as __private_extern__ (aka visibility=hidden) and will not be global in the output file.

See the man page documentation for ld(1) on macOS for more details.

families

A list of device families supported by this extension. Valid values are iphone and ipad; at least one must be specified.

frameworks

A list of framework targets (see ios_framework) that this target depends on.

hdrs

A list of .h files that will be publicly exposed by this framework. These headers should have framework-relative imports, and if non-empty, an umbrella header named %{bundle_name}.h will also be generated that imports all of the headers listed here.

ipa_post_processor

A tool that edits this target's archive after it is assembled but before it is signed. The tool is invoked with a single command-line argument that denotes the path to a directory containing the unzipped contents of the archive; this target's bundle will be the directory's only contents.

Any changes made by the tool must be made in this directory, and the tool's execution must be hermetic given these inputs to ensure that the result can be safely cached.

linkopts

A list of strings representing extra flags that should be passed to the linker.

minimum_os_version

A required string indicating the minimum OS version supported by the target, represented as a dotted version number (for example, "9.0").

platform_type

resources

A list of resources or files bundled with the bundle. The resources will be stored in the appropriate resources location within the bundle.

stamp

Enable link stamping. Whether to encode build information into the binary. Possible values:

  • stamp = 1: Stamp the build information into the binary. Stamped binaries are only rebuilt when their dependencies change. Use this if there are tests that depend on the build information.
  • stamp = 0: Always replace build information by constant values. This gives good build result caching.
  • stamp = -1: Embedding of build information is controlled by the --[no]stamp flag.

strings

A list of .strings files, often localizable. These files are converted to binary plists (if they are not already) and placed in the root of the final bundle, unless a file's immediate containing directory is named *.lproj, in which case it will be placed under a directory with the same name in the bundle.

umbrella_header

An optional single .h file to use as the umbrella header for this framework. Usually, this header will have the same name as this target, so that clients can load the header using the #import <MyFramework/MyFramework.h> format. If this attribute is not specified (the common use case), an umbrella header will be generated under the same name as this target.

version

An apple_bundle_version target that represents the version for this target. See apple_bundle_version.


ios_sticker_pack_extension

Builds and bundles an iOS Sticker Pack Extension.

Example usage (generated)

load("@rules_apple//apple:ios.doc.bzl", "ios_sticker_pack_extension")

ios_sticker_pack_extension(
    # A unique name for this target.
    name = "",
    # The bundle ID (reverse-DNS path followed by app name) for this target.
    bundle_id = "",
    # A list of device families supported by this extension
    families = [],
    # A list of .plist files that will be merged to form the Info.plist for this target
    infoplists = [],
    # A required string indicating the minimum OS version supported by the target, represented as a
    minimum_os_version = "",
)

name

A unique name for this target.

app_icons

Files that comprise the app icons for the application. Each file must have a containing directory named *..xcstickers/*..stickersiconset and there may be only one such ..stickersiconset directory in the list.

bundle_id

The bundle ID (reverse-DNS path followed by app name) for this target.

bundle_name

The desired name of the bundle (without the extension). If this attribute is not set, then the name of the target will be used instead.

entitlements

The entitlements file required for device builds of this target. If absent, the default entitlements from the provisioning profile will be used.

The following variables are substituted in the entitlements file: $(CFBundleIdentifier) with the bundle ID of the application and $(AppIdentifierPrefix) with the value of the ApplicationIdentifierPrefix key from the target's provisioning profile.

entitlements_validation

An entitlements_validation_mode to control the validation of the requested entitlements against the provisioning profile to ensure they are supported.

executable_name

The desired name of the executable, if the bundle has an executable. If this attribute is not set, then the name of the bundle_name attribute will be used if it is set; if not, then the name of the target will be used instead.

families

A list of device families supported by this extension. Valid values are iphone and ipad; at least one must be specified.

infoplists

A list of .plist files that will be merged to form the Info.plist for this target. At least one file must be specified. Please see Info.plist Handling for what is supported.

ipa_post_processor

A tool that edits this target's archive after it is assembled but before it is signed. The tool is invoked with a single command-line argument that denotes the path to a directory containing the unzipped contents of the archive; this target's bundle will be the directory's only contents.

Any changes made by the tool must be made in this directory, and the tool's execution must be hermetic given these inputs to ensure that the result can be safely cached.

minimum_os_version

A required string indicating the minimum OS version supported by the target, represented as a dotted version number (for example, "9.0").

platform_type

provisioning_profile

The provisioning profile (.mobileprovision file) to use when creating the bundle. This value is optional for simulator builds as the simulator doesn't fully enforce entitlements, but is required for device builds.

resources

A list of resources or files bundled with the bundle. The resources will be stored in the appropriate resources location within the bundle.

sticker_assets

List of sticker files to bundle. The collection of assets should be under a folder named *.*.xcstickers. The icons go in a *.stickersiconset (instead of *.appiconset); and the files for the stickers should all be in Sticker Pack directories, so *.stickerpack/*.sticker or *.stickerpack/*.stickersequence.

strings

A list of .strings files, often localizable. These files are converted to binary plists (if they are not already) and placed in the root of the final bundle, unless a file's immediate containing directory is named *.lproj, in which case it will be placed under a directory with the same name in the bundle.

version

An apple_bundle_version target that represents the version for this target. See apple_bundle_version.


ios_ui_test

iOS UI Test rule.

Builds and bundles an iOS UI .xctest test bundle. Runs the tests using the provided test runner when invoked with bazel test. When using Tulsi to run tests built with this target, runner will not be used since Xcode is the test runner in that case.

To run the same test on multiple simulators/devices see ios_ui_test_suite.

The following is a list of the ios_ui_test specific attributes; for a list of the attributes inherited by all test rules, please check the Bazel documentation.

Example usage (generated)

load("@rules_apple//apple:ios.doc.bzl", "ios_ui_test")

ios_ui_test(
    # A unique name for this target.
    name = "",
    deps = [],
    # The runner target that will provide the logic on how to run the tests
    runner = "",
)

name

A unique name for this target.

data

Files to be made available to the test during its execution.

deps

env

Dictionary of environment variables that should be set during the test execution.

platform_type

runner

The runner target that will provide the logic on how to run the tests. Needs to provide the AppleTestRunnerInfo provider.

test_host


ios_unit_test

Builds and bundles an iOS Unit .xctest test bundle. Runs the tests using the provided test runner when invoked with bazel test. When using Tulsi to run tests built with this target, runner will not be used since Xcode is the test runner in that case.

ios_unit_test targets can work in two modes: as app or library tests. If the test_host attribute is set to an ios_application target, the tests will run within that application's context. If no test_host is provided, the tests will run outside the context of an iOS application. Because of this, certain functionalities might not be present (e.g. UI layout, NSUserDefaults). You can find more information about app and library testing for Apple platforms here.

To run the same test on multiple simulators/devices see ios_unit_test_suite.

The following is a list of the ios_unit_test specific attributes; for a list of the attributes inherited by all test rules, please check the Bazel documentation.

Example usage (generated)

load("@rules_apple//apple:ios.doc.bzl", "ios_unit_test")

ios_unit_test(
    # A unique name for this target.
    name = "",
    deps = [],
    # The runner target that will provide the logic on how to run the tests
    runner = "",
)

name

A unique name for this target.

data

Files to be made available to the test during its execution.

deps

env

Dictionary of environment variables that should be set during the test execution.

platform_type

runner

The runner target that will provide the logic on how to run the tests. Needs to provide the AppleTestRunnerInfo provider.

test_host


Macros and Functions

ios_ui_test_suite

Generates a test_suite containing an ios_ui_test for each of the given runners.

ios_ui_test_suite takes the same parameters as ios_ui_test, except runner is replaced by runners.

Example usage (generated)

load("@rules_apple//apple:ios.doc.bzl", "ios_ui_test_suite")

ios_ui_test_suite(
    name = "",
)

name

runners

a list of runner targets

kwargs

passed to the [ios_ui_test]


ios_unit_test_suite

Generates a test_suite containing an ios_unit_test for each of the given runners.

ios_unit_test_suite takes the same parameters as ios_unit_test, except runner is replaced by runners.

Example usage (generated)

load("@rules_apple//apple:ios.doc.bzl", "ios_unit_test_suite")

ios_unit_test_suite(
    name = "",
)

name

runners

a list of runner targets

kwargs

passed to the [ios_unit_test]