Skip to content

Add minimum_os_version attribute to Swift rules#1691

Open
jpsim wants to merge 2 commits into
bazelbuild:mainfrom
jpsim:jp/minimum-os-version
Open

Add minimum_os_version attribute to Swift rules#1691
jpsim wants to merge 2 commits into
bazelbuild:mainfrom
jpsim:jp/minimum-os-version

Conversation

@jpsim
Copy link
Copy Markdown
Contributor

@jpsim jpsim commented Apr 21, 2026

Adds a minimum_os_version string attribute on swift_binary, swift_library, swift_test, swift_compiler_plugin, swift_overlay, and swift_proto_library. On Apple/Xcode toolchains, when set, the value is used to construct the OS component of the target triple passed to swiftc (for example, apple-macos13.0). When unset, the target triple from the selected platform configuration is used unchanged.

Also exposes minimum_os_version on swift_common.compile and adds a target_triples.with_os_version helper for constructing versioned triples.

This is a simpler alternative to #1645, which depended on upstream Bazel work to expose XcodeSdkVariantInfo via xcode_sdk_variant rules. That work has stalled while the Xcode rules migrate out of Bazel core into apple_support, so this change overrides the OS version directly in the Xcode toolchain without depending on new Bazel providers.

Refs:

Adds a `minimum_os_version` string attribute on `swift_binary`,
`swift_library`, `swift_test`, `swift_compiler_plugin`,
`swift_overlay`, and `swift_proto_library`. On Apple/Xcode
toolchains, when set, the value is used to construct the OS
component of the target triple passed to `swiftc` (for example,
`apple-macos13.0`). When unset, the target triple from the
selected platform configuration is used unchanged.

Also exposes `minimum_os_version` on `swift_common.compile` and
adds a `target_triples.with_os_version` helper for constructing
versioned triples.

This is a simpler alternative to bazelbuild#1645, which depended on upstream
Bazel work to expose `XcodeSdkVariantInfo` via `xcode_sdk_variant`
rules. That work has stalled while the Xcode rules migrate out of
Bazel core into apple_support, so this change overrides the OS
version directly in the Xcode toolchain without depending on new
Bazel providers.

Refs:
* bazelbuild#1645
* cgrindel/rules_swift_package_manager#892
* bazelbuild/bazel#21991
* bazelbuild/bazel#28028
@jpsim
Copy link
Copy Markdown
Contributor Author

jpsim commented Apr 22, 2026

The failures on "last green" ci jobs are unrelated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants