Announcing Bazel support for Swift on Apple platforms and Linux

(Mods: I hope this kind of general announcement is not inappropriate for a top-level post in "Related Projects"; the closest other place I could see was "Using Swift" but this isn't really a Swift-language-related post. If this doesn't belong here, please move or remove it with my apologies.)

Bazel is the open-source build and testing system developed by and in use at Google. If you use it or have considered using it, I'm happy to announce that we've just open-sourced a new repository of build rules to support Swift: GitHub - bazelbuild/rules_swift: Bazel rules to build Swift on Apple and Linux platforms

We've actually had some support for Swift for Apple platforms for a while, in our rules_apple repository, but this only consisted of a single swift_library rule meant to build Swift modules for iOS/macOS/tvOS/watchOS applications. The new repository is a complete rewrite from the ground up that also adds support for Swift on Linux.

The rules are in the early beta stages, so there may be bugs and missing features. If you use them and hit any problems, please file them on GitHub!

I don't want this announcement to come off like a sales pitch so I'm not going to focus on why you should use Bazel (for Swift or otherwise) here—I just want to make folks aware of the new support, especially if they're already familiar with the build system. But I definitely encourage everyone to check it out and make up their own minds.

However, I will go ahead and pre-answer one question that might naturally come up with an announcement like this:

Is this intended to compete with or snub Swift Package Manager?

Definitely not. In fact, I would love to have better integration between SwiftPM and Bazel and have them augment each other. If someone is already invested in using Bazel as their build system, then we should make the existing Swift packages that are out in the world easier for them to use. Some way of being able to point a Bazel build at a GitHub repository and have SwiftPM build those packages and integrate the artifacts into the rest of the Bazel build would be an awesome addition (and it's already a feature request we're tracking).

9 Likes