Accept Label values in Xcode threshold references (#678)

The documented `after` argument accepted string references but failed
when passed a `Label`, because companion-target construction called
string methods. Construct the companion with `same_package_label` so the
original repository and package identity survive calls from other
repositories.

---------

Co-authored-by: Adin Cebic <cebic.ad@gmail.com>
3 files changed
tree: 03d846a4e36186b7637aa90a89eb9d72cb5a7b3f
  1. .bazelci/
  2. .bcr/
  3. .github/
  4. build_settings/
  5. configs/
  6. constraints/
  7. crosstool/
  8. doc/
  9. lib/
  10. platforms/
  11. rules/
  12. test/
  13. toolchain/
  14. tools/
  15. xcode/
  16. .bazelrc
  17. .clang-format
  18. .gitattributes
  19. .gitignore
  20. .pre-commit-config.yaml
  21. BUILD
  22. CODEOWNERS
  23. CONTRIBUTING.md
  24. LICENSE
  25. MODULE.bazel
  26. README.md
README.md

Apple Support for Bazel

This repository contains the Apple CC toolchain, Apple related platforms and constraints definitions, and small helper functions for rules authors targeting Apple platforms.

If you want to build iOS, tvOS, visionOS, watchOS, or macOS apps, use rules_apple.

If you want to build Swift use rules_swift.

See the documentation for the helper rules provided by this repository.

Installation

Copy the MODULE.bazel snippet from the releases page into your project.

Toolchain setup

The Apple CC toolchain in this repository provides toolchains for building for Apple platforms besides macOS. Since Bazel 7 this toolchain is required when targeting those platforms.

The toolchain supports using a full Xcode installation or the Xcode Command Line Tools.

Supported Xcode versions

apple_support is heavily tied to Xcode / clang's current feature set. We have the ability to add / remove flags based on the current versions, but overtime we like to reduce the maintenance cost of this type of branch and remove support for older versions. We attempt to do this conservatively and are open to supporting more versions if there is a need. These versions roughly correspond to the versions of the separate Xcode Command Line Tools releases, but those are not versioned in the same way.

Xcode releaseMinimum supported rules versionFinal supported rules version
27.xunknowncurrent
26.xunknowncurrent
16.xunknowncurrent

Bazel 7+ Setup

For Bazel 7+ the only setup that is required is to have apple_support in your MODULE.bazel (even if you're not referencing it directly), which you can copy from the releases page into your project.

If you also depend on rules_cc, apple_support must come above rules_cc in your MODULE.bazel file because Bazel selects toolchains based on which is registered first.

Toolchain configuration

There are many different flags you can flip to configure how the toolchain works. Here are some of the more commonly useful ones:

  • Setting DEVELOPER_DIR in the environment. This is recommended so that the toolchain can be invalidated when the DEVELOPER_DIR changes, which ensures that toolchain binaries will be rebuilt with the new version of Xcode so that caches are correctly shared across machines.
  • Setting BAZEL_ALLOW_NON_APPLICATIONS_XCODE=1 in the environment (or using --repo_env) allows the toolchain to discover Xcode versions outside of the /Applications directory to avoid header inclusion errors from bazel. This is not enabled by default because /Applications is the standard directory, and this improves toolchain setup performance.