a2 / rules_xcodeproj

Bazel rules for generating Xcode projects.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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 if another issue already exists and comment on it, and if not, file an issue!

Features

  • Build Bazel targets with Xcode (not Bazel), with full support for:
    • Indexing (i.e. autocomplete, syntax highlighting, jump to definition)
    • Debugging
    • Inline warnings and errors
    • Fix-its
    • Tests (Unit and UI)
    • SwiftUI Previews

Note: Not all rules are supported yet, and the rules that are supported don't have full support yet. See the 1.0 Project for details on progress towards the 1.0 release. Here are a few of the planned high level features:

Compatibility

  • macOS 12.0-12.3
  • Xcode 13.0-13.3
  • Bazel 5.1.0
  • rules_swift 0.27.0
  • rules_apple 0.34.0

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

Please refer to the release notes for a given release to see which versions it is compatible with.

Quick setup

Add the following to your WORKSPACE file to add the external repositories, replacing the version number in the url attribute with the version of the rules you wish to depend on:

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

http_archive(
    name = "com_github_buildbuddy_io_rules_xcodeproj",
    sha256 = "e82b24c55e479905383d1567d7617a14d1995638bf78b468218f7a44c176ce15",
    url = "https://github.com/buildbuddy-io/rules_xcodeproj/releases/download/0.1.0/release.tar.gz",
)

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

xcodeproj_rules_dependencies()

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()

Examples

Minimal example:

load("@build_bazel_rules_apple//apple:ios.bzl", "ios_application")
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
load(
    "@com_github_buildbuddy_io_rules_xcodeproj//xcodeproj:xcodeproj.bzl",
    "xcodeproj",
)

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

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

xcodeproj(
    name = "xcodeproj",
    project_name = "App",
    targets = [
        ":App",
    ],
    tags = ["manual"],
)

You can then create the Xcode project with:

bazel run //:xcodeproj

The generated project will be in the workspace at App.xcodeproj.

See the examples directory for sample setups.

About

Bazel rules for generating Xcode projects.

License:MIT License


Languages

Language:Swift 51.7%Language:Starlark 47.6%Language:Shell 0.7%