Using a system-wide installed Swift snapshot on macOS can emit a nonexistent linker search path.
I installed this snapshot:
https://download.swift.org/development/xcode/swift-DEVELOPMENT-SNAPSHOT-2026-03-16-a/swift-DEVELOPMENT-SNAPSHOT-2026-03-16-a-osx.pkg
Then I built one of my Swift projects with:
bazel build ... --action_env=TOOLCHAINS=org.swift.64202603161a
The bundle identifier was extracted with:
plutil -extract CFBundleIdentifier raw -o - \
/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2026-03-16-a.xctoolchain/Info.plist
Basic compilation works, but the link step emits this warning:
ld: warning: search path '__BAZEL_SWIFT_TOOLCHAIN_PATH__/usr/lib/swift/macosx' not found
Root cause
After digging into this, the issue appears to be a placeholder mismatch inside rules_swift.
rules_swift emits __BAZEL_SWIFT_TOOLCHAIN_PATH__ into linker flags for the custom toolchain path, but apple_support only substitutes __BAZEL_CUSTOM_XCODE_TOOLCHAIN_PATH__ during link argument processing.
That leaves this linker flag unresolved:
-L__BAZEL_SWIFT_TOOLCHAIN_PATH__/usr/lib/swift/macosx
Expected behavior
When TOOLCHAINS is used with an installed Swift snapshot toolchain, rules_swift should emit a linker-side placeholder that is actually resolved during link argument processing, so no nonexistent search path warning is produced.
Proposed fix
Use the Swift placeholder for Swift-side worker/tool behavior, but use the linker-compatible custom Xcode toolchain placeholder when constructing linker search paths for custom toolchains.
I have a small patch and regression test for this and can open a PR.
Using a system-wide installed Swift snapshot on macOS can emit a nonexistent linker search path.
I installed this snapshot:
https://download.swift.org/development/xcode/swift-DEVELOPMENT-SNAPSHOT-2026-03-16-a/swift-DEVELOPMENT-SNAPSHOT-2026-03-16-a-osx.pkg
Then I built one of my Swift projects with:
The bundle identifier was extracted with:
Basic compilation works, but the link step emits this warning:
Root cause
After digging into this, the issue appears to be a placeholder mismatch inside
rules_swift.rules_swiftemits__BAZEL_SWIFT_TOOLCHAIN_PATH__into linker flags for the custom toolchain path, but apple_support only substitutes__BAZEL_CUSTOM_XCODE_TOOLCHAIN_PATH__during link argument processing.That leaves this linker flag unresolved:
Expected behavior
When
TOOLCHAINSis used with an installed Swift snapshot toolchain,rules_swiftshould emit a linker-side placeholder that is actually resolved during link argument processing, so no nonexistent search path warning is produced.Proposed fix
Use the Swift placeholder for Swift-side worker/tool behavior, but use the linker-compatible custom Xcode toolchain placeholder when constructing linker search paths for custom toolchains.
I have a small patch and regression test for this and can open a PR.