rules_xcodeproj
2.11.0
published 4 days ago
556 stars
92 forks
24 watchers
MIT License
public
2 assets
1,829,815 downloads
10 MB
Compatibility level 1
JH+sQkvoZyDlHMd9WpUYdq4natpb9x5u2+W3/1P9NpA=
2.11.0
March 25, 2025

What’s Changed

Adjusted

  • We now default LANG to en_US.UTF-8 in project generation: #3143
  • Indexstore .filelist creation has been simplified: #3144
  • WriteTargetBuildSettings can now optionally use remote cache or RBE: #3149
  • We now use --action_env=TOOLCHAINS= instead of --define=SWIFT_CUSTOM_TOOLCHAIN=: #3123
  • Changed instances of --experimental_remote_download_regex to --remote_download_regex: #3125

Fixed

  • We now use md5sum when not on macOS: #3145
  • xcode-select or DEVELOPER_DIR are no longer required to generate a project: #3147
  • Fixed incremental_installer.sh when running on Linux: #3148
  • swift_compiler_plugin sources are now added to the generated project: #3142
  • Removed duplicate post/pre actions: #3122

Full Changelog

https://github.com/buildbuddy-io/rules_xcodeproj/compare/2.10.0...2.11.0

Contributors

  • @brentleyjones
  • @luispadron
  • @adincebic
  • @karim-alweheshy
  • @maxwellE
  • @sebastianv1

Bzlmod Snippet

bazel_dep(name = "rules_xcodeproj", version = "2.11.0")

release.tar.gz’s integrity: sha256-JH+sQkvoZyDlHMd9WpUYdq4natpb9x5u2+W3/1P9NpA=

Workspace Snippet

Please use the release asset (release.tar.gz) from your Bazel WORKSPACE instead of GitHub's source asset to reduce download size and improve reproducibility.

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "rules_xcodeproj",
    integrity = "sha256-JH+sQkvoZyDlHMd9WpUYdq4natpb9x5u2+W3/1P9NpA=",
    url = "https://github.com/MobileNativeFoundation/rules_xcodeproj/releases/download/2.11.0/release.tar.gz",
)

load(
    "@rules_xcodeproj//xcodeproj:repositories.bzl",
    "xcodeproj_rules_dependencies",
)

xcodeproj_rules_dependencies()

load("@bazel_features//:deps.bzl", "bazel_features_deps")

bazel_features_deps()

load(
    "@build_bazel_rules_apple//apple:repositories.bzl",
    "apple_rules_dependencies",
)

apple_rules_dependencies()

load(
    "@build_bazel_rules_swift//swift:repositories.bzl",
    "swift_rules_dependencies",
)

swift_rules_dependencies()

load(
    "@build_bazel_rules_swift//swift:extras.bzl",
    "swift_rules_extra_dependencies",
)

swift_rules_extra_dependencies()

load(
    "@build_bazel_apple_support//lib:repositories.bzl",
    "apple_support_dependencies",
)

apple_support_dependencies()
Deps:
Assets:

rules_xcodeproj

This repository contains rules for Bazel that can be used to generate Xcode projects from targets in your workspace.

If you run into any problems with these rules, please check our FAQ, check if another issue already exists and comment on it, or file a new issue!

Features

  • Full support for Xcode features:
    • Indexing (i.e. autocomplete, syntax highlighting, jump to definition)
    • Debugging
    • Runtime sanitizers
    • Inline warnings and errors
    • Fix-its (currently only in BwX mode)
    • Test selection and running
    • Embedded Targets (App Clips, App Extensions, and Watch Apps)
    • Dynamic frameworks
    • Xcode Previews
  • Focused Projects
    • Include a subset of your targets in Xcode
    • Unfocused targets are built with Bazel
    • Works in BwX mode as well!
  • Comprehensive Bazel rules support
    • Core Bazel C/C++/Objective-C
    • rules_swift
    • rules_apple
    • rules_ios
    • Most likely your custom rules as well!
  • Minimal configuration needed (see the usage section below)
  • It “just works”

We’ve also documented the high-level design goals of the ruleset.

Projects using rules_xcodeproj

  • amo
  • BazelPods
  • Cash App
  • Envoy Mobile
  • Ergatta
  • Faire Wholesale
  • Gojek
  • Lyft
  • Mercari
  • Reddit
  • Robinhood
  • Slack
  • Snap
  • Spotify
  • Square
  • SwiftLint
  • Ten Ten
  • Tinder
  • Tokopedia

If you are also using rules_xcodeproj for your project, feel free to open a PR to include it in the list above.

Compatibility

rules_xcodeproj Bazel rules_apple rules_swift Xcode macOS Supporting Branch
2.10.0+ 7.0-9.x 3.16.1+ 1.18.0+ 13.3–15.x 13–14.x main
1.17.0+ 6.3-7.x 1.0.1–2.x 1.x 13.3–15.x 13–14.x -
1.16.0 6.3-7.x 1.0.1–2.x 1.x 13.3–15.2 13–14.x -
1.14.0-1.15.0 6.1-7.x 1.0.1–2.x 1.x 13.3–15.2 13–14.x -
1.7.0-1.13.0 5.3–6.x 1.0.1–2.x 1.x 13.3–15.2 12–13.x -
1.4.0-1.6.0 5.3–6.x 1.0.1–2.x 1.x 13.3–14.3 12–13.x -
1.0-1.3.3 5.3–6.x 1.0.1–2.x 1.x 13.3–14.2 12–13.x -

More versions of these tools and rulesets might be supported, but these are the ones we’ve officially tested with.

Installation

From the release you wish to use, copy the Bzlmod or WORKSPACE snippet into your repository. If you want to manually build a release archive, you can use this command: bazel build //distribution:release.

Usage

Please see the documentation in the docs directory and examples in the examples directory.

Simple iOS example

Given a root level BUILD file:

load(
  "@build_bazel_rules_apple//apple:ios.bzl",
  "ios_application",
  "ios_unit_test",
)
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
load(
    "@rules_xcodeproj//xcodeproj:defs.bzl",
    "top_level_target",
    "xcodeproj",
)

xcodeproj(
    name = "xcodeproj",
    project_name = "App",
    tags = ["manual"],
    top_level_targets = [
        top_level_target(":App", target_environments = ["device", "simulator"]),
        ":Tests",
    ],
)

ios_application(
    name = "App",
    bundle_id = "com.example.app",
    families = ["iphone", "ipad"],
    infoplists = [":Info.plist"],
    minimum_os_version = "15.0",
    visibility = ["//visibility:public"],
    deps = [":Lib"],
)

swift_library(
    name = "Lib",
    srcs = glob(["src/*.swift"]),
)

ios_unit_test(
    name = "Tests",
    bundle_id = "com.example.tests",
    minimum_os_version = "15.0",
    test_host = ":App",
    visibility = ["//visibility:public"],
    deps = [":TestLib"],
)

swift_library(
    name = "TestLib",
    srcs = glob(["test/*.swift"]),
)

You can then create the Xcode project with:

bazel run //:xcodeproj

The generated project will be in the workspace next to the BUILD file at App.xcodeproj.

Acknowledgements