jerrymarino / rules_ios

Bazel rules for building iOS applications and frameworks

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

iOS Rules for Bazel

master

⚠️ This is alpha software. We are developing these rules in the open so you should only use them if you know what you are doing and are willing to help develop them.

These rules provide some macros and rules that make it easier to build iOS application with Bazel. The heavy lifting of compiling, and packaging is still done by the existing objc_library rule in Bazel, and by the swift_library rule available from rules_swift.

Bazel version required by current rules is here

Reference documentation

Click here for the documentation.

Quick setup

Add the following lines to your WORKSPACE file. Note that since rules_swift and rules_apple no longer create releases, the versions are hardcoded to commit sha's that are known to work. You can see the particular commit sha's in repositories.bzl.

load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")

git_repository(
    name = "build_bazel_rules_ios",
    remote = "https://github.com/bazel-ios/rules_ios.git",
    branch = "master",
)

load(
    "@build_bazel_rules_ios//rules:repositories.bzl",
    "rules_ios_dependencies"
)

rules_ios_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_apple_support//lib:repositories.bzl",
    "apple_support_dependencies",
)

apple_support_dependencies()

load(
    "@com_google_protobuf//:protobuf_deps.bzl",
    "protobuf_deps",
)

protobuf_deps()

Examples

Minimal example:

load("@build_bazel_rules_ios//rules:app.bzl", "ios_application")

ios_application(
    name = "iOS-App",
    srcs = glob(["*.m"]),
    bundle_id = "com.example.ios-app",
    entitlements = "ios.entitlements",
    families = [
        "iphone",
        "ipad",
    ],
    launch_storyboard = "LaunchScreen.storyboard",
    minimum_os_version = "12.0",
    visibility = ["//visibility:public"],
)

See the tests directory for sample applications.

Special notes about debugging xcode projects

Note that when generating Xcode projects, it is necessary to supply the --@build_bazel_rules_ios//rules:local_debug_options_enabled so that debugging of swift files will work.

Debugging does not work in sandbox mode, due to issue #108. The workaround for now is to disable sandboxing in the .bazelrc file.

About

Bazel rules for building iOS applications and frameworks

License:Apache License 2.0


Languages

Language:Starlark 64.1%Language:Shell 16.4%Language:C 14.7%Language:Objective-C 1.5%Language:Python 1.5%Language:Swift 1.2%Language:Ruby 0.6%Language:Objective-C++ 0.0%Language:MATLAB 0.0%Language:C++ 0.0%