Make libtool wrapper handle ar args When interoping with other build systems, like through rules_rust or rules_foreign_cc, they often expect the `AR` env var to be set to the literal `ar` command line tool. Apple currently ships an `ar` from the `cctools` repo that doesn't have the same hermeticity flags as `llvm-ar` (specifically it is lacking `D`). Because of this we use `libtool` which supports `-D`. This change allows callers to not care about that difference and pretend our wrapper is `ar`, and we still correctly create archives with libtool.
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.
Copy the MODULE.bazel snippet from the releases page into your project.
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.
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.
There are many different flags you can flip to configure how the toolchain works. Here are some of the more commonly useful ones:
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.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.