A Bazel module for consuming remote or local XCFrameworks for iOS/MacOS applications.
Tested with Bazel 8.x and 9.x.
Add the following to your MODULE.bazel file:
bazel_dep(name = "rules_apple_remote_xcframework", version = "1.0.1")
remote_xcframework = use_extension(
"@rules_apple_remote_xcframework//remote_xcframework:extensions.bzl",
"remote_xcframework_extension",
)
remote_xcframework.xcframework(
name = "MyRemoteFramework",
url = "https://my.server.com/path/to/MyFramework.xcframework.zip",
sha256 = "...",
strip_prefix = "MyFramework-1.2.3",
)
use_repo(remote_xcframework, "MyRemoteFramework")
For a local archive on disk, use an absolute filesystem path instead of url:
remote_xcframework.xcframework(
name = "MyLocalFramework",
path = "/absolute/path/to/MyFramework.xcframework.zip",
strip_prefix = "MyFramework-1.2.3",
)
use_repo(remote_xcframework, "MyLocalFramework")
This module depends on rules_apple and rules_swift and is intended for Bzlmod-based projects.
You can now depend on the downloaded framework in your swift_library or ios_application targets:
swift_library(
name = "my_lib",
srcs = ["..."],
deps = [
"@MyRemoteFramework//:MyRemoteFramework",
],
)
See examples/ for a working end-to-end example.
Each remote_xcframework.xcframework(...) tag must set exactly one source:
url: remote archive download. sha256 is required.path: absolute filesystem path to a local archive or .xcframework directory. sha256 must be omitted.Relative paths are not supported.
The extension supports both dynamic and static XCFrameworks. By default, frameworks are treated as dynamic.
Dynamic frameworks are the default behavior. You can omit the type attribute:
remote_xcframework.xcframework(
name = "MyDynamicFramework",
url = "https://my.server.com/path/to/MyDynamicFramework.xcframework.zip",
sha256 = "...",
strip_prefix = "MyDynamicFramework-1.0.0",
)
Or explicitly specify type = "dynamic":
remote_xcframework.xcframework(
name = "MyDynamicFramework",
path = "/absolute/path/to/MyDynamicFramework.xcframework.zip",
strip_prefix = "MyDynamicFramework-1.0.0",
type = "dynamic",
)
For static XCFrameworks, set type = "static":
remote_xcframework.xcframework(
name = "MyStaticFramework",
url = "https://my.server.com/path/to/MyStaticFramework.xcframework.zip",
sha256 = "...",
strip_prefix = "MyStaticFramework-1.0.0",
type = "static",
)
When to use static vs dynamic frameworks: