By the end of this guide you will have a fully working Xcode project generated from a Bazel workspace — complete with an iOS app target, a Swift library, and a unit test suite. The project will support both device and simulator destinations, and you’ll be able to build, run, and debug it entirely within Xcode while Bazel remains the underlying build system.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.
Prerequisites
Before you begin, make sure you have the following in place:
- Bazel 8.0.0 or later installed (via Bazelisk is recommended).
- An Apple-platform Bazel workspace that already uses
rules_appleandrules_swift. If you’re starting from scratch, set those up first before adding rules_xcodeproj. - rules_xcodeproj installed in your
MODULE.bazel. If you haven’t done that yet, follow the Installation guide and come back here when you’re ready. - Xcode installed on your Mac (any version supported by your chosen rules_xcodeproj release — see the compatibility table).
Define an xcodeproj Target
Add the following to your root-level A few things to note about the
BUILD file (or create one if it doesn’t exist yet). This example sets up a minimal iOS application with a Swift library and a unit test target:BUILD
xcodeproj rule:project_namesets the name of the generated.xcodeprojbundle.top_level_targetslists the Bazel targets you want represented in Xcode.top_level_targetlets you specify which environments (device, simulator) apply to each target.tags = ["manual"]prevents thexcodeprojtarget from being built accidentally by wildcard commands likebazel build //....
Your workspace will need an
Info.plist file alongside the BUILD file for the ios_application rule. You can start with a minimal plist or point to one generated by rules_apple.Generate the Xcode Project
Run the following command from the root of your workspace:Bazel will analyze your build graph, run the rules_xcodeproj generator, and write a When the command exits successfully,
.xcodeproj bundle next to your BUILD file. You should see output similar to:App.xcodeproj will be present in your workspace root — right beside the BUILD file.What to Do Next
Now that you have a working generated project, explore the more powerful features of rules_xcodeproj:Focused Projects
Limit the Xcode project to just the targets you’re actively working on. Unfocused dependencies are built by Bazel in the background.
Custom Schemes
Use the
xcschemes API to define exactly the build, run, test, and profile actions you need — all from your BUILD files.Bazel Configs
Fine-tune how Bazel behaves inside Xcode by customizing the
rules_xcodeproj family of .bazelrc configs for builds, index builds, and SwiftUI Previews.Build Modes
Choose between Build with Xcode (BwX) and Build with Bazel (BwB) to match your team’s preferred workflow and caching strategy.