Skip to content

Commit 64e9631

Browse files
authored
Fix Metal toolchains in Xcode 26 betas (#3213)
Fixes: ``` Error: TOOLCHAINS was set to 'com.apple.dt.toolchain.Metal.32023' but the default toolchain was found, that likely means a matching toolchain isn't installed ``` Apparently `$toolchain` either was never set for Metal toolchains in earlier Xcode versions or Xcode didn't complain when it was set in `action_env`. I tested on Xcode 16 and it was never there while it definitely shows up in Xcode 26 Beta 3. I think version check may not be needed here at all. If yes, please do let me know what would be suggested way of performing the check. I tried calling `xcodebuild -version` but that seem to randomly fail for some people so I removed it. Signed-off-by: Adin Cebic <[email protected]>
1 parent 75e98bd commit 64e9631

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

xcodeproj/internal/templates/bazel_build.sh

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,20 @@ readonly base_pre_config_flags=(
9797
# Custom Swift toolchains
9898

9999
if [[ -n "${TOOLCHAINS-}" ]]; then
100-
toolchain="${TOOLCHAINS%% *}"
101-
if [[ "$toolchain" == "com.apple.dt.toolchain.XcodeDefault" ]]; then
102-
unset toolchain
100+
# We remove all Metal toolchains from the list first
101+
toolchains_array=($TOOLCHAINS)
102+
filtered_toolchains=()
103+
for tc in "${toolchains_array[@]}"; do
104+
if [[ "$tc" != "com.apple.dt.toolchain.Metal"* ]]; then
105+
filtered_toolchains+=("$tc")
106+
fi
107+
done
108+
109+
if [[ ${#filtered_toolchains[@]} -gt 0 ]]; then
110+
toolchain="${filtered_toolchains[0]}"
111+
if [[ "$toolchain" == "com.apple.dt.toolchain.XcodeDefault" ]]; then
112+
unset toolchain
113+
fi
103114
fi
104115
fi
105116

0 commit comments

Comments
 (0)