Unable to compile Core Image filter on Xcode 26 due to missing Metal toolchain

I have a Core Image filter in my app that uses Metal. I cannot compile it because it complains that the executable tool metal is not available, but I have installed it in Xcode.

If I go to the "Components" section of Xcode Settings, it shows it as downloaded. And if I run the suggested command, it also shows it as installed. Any advice?

Xcode Version Version 26.0 beta (17A5241e)

Build Output


Showing All Errors Only

Build target Lessons of project StudyJapanese with configuration Light

RuleScriptExecution /Users/chris/Library/Developer/Xcode/DerivedData/StudyJapanese-glbneyedpsgxhscqueifpekwaofk/Build/Intermediates.noindex/StudyJapanese.build/Light-iphonesimulator/Lessons.build/DerivedSources/OtsuThresholdKernel.ci.air /Users/chris/Code/SerpentiSei/Shared/iOS/CoreImage/OtsuThresholdKernel.ci.metal normal undefined_arch (in target 'Lessons' from project 'StudyJapanese')
    cd /Users/chris/Code/SerpentiSei/StudyJapanese
    /bin/sh -c xcrun\ metal\ -w\ -c\ -fcikernel\ \"\$\{INPUT_FILE_PATH\}\"\ -o\ \"\$\{SCRIPT_OUTPUT_FILE_0\}\"'
'

error: error: cannot execute tool 'metal' due to missing Metal Toolchain; use: xcodebuild -downloadComponent MetalToolchain

/Users/chris/Code/SerpentiSei/StudyJapanese/error:1:1: cannot execute tool 'metal' due to missing Metal Toolchain; use: xcodebuild -downloadComponent MetalToolchain



Build failed    6/9/25, 8:31 PM    27.1 seconds

Result of xcodebuild -downloadComponent MetalToolchain (after switching Xcode-beta.app with xcode-select)

xcodebuild -downloadComponent MetalToolchain
Beginning asset download...
Downloaded asset to: /System/Library/AssetsV2/com_apple_MobileAsset_MetalToolchain/4d77809b60771042e514cfcf39662c6d1c195f7d.asset/AssetData/Restore/022-19457-035.dmg
Done downloading: Metal Toolchain (17A5241c).

Screenshots from Xcode

Result of "Copy Information" Metal Toolchain 26.0 [com.apple.MobileAsset.MetalToolchain: 17.0 (17A5241c)] (Installed)

Answered by DTS Engineer in 842416022

This is a known issue, and it's in the Xcode 26 Beta Release Notes.

Xcodebuild may fail to find the downloaded metal toolchain when building a project with metal shaders by command line. (152810434)

The workaround (noted in that release note) is to run these commands in Terminal:

xcodebuild -downloadComponent metalToolchain -exportPath /tmp/MyMetalExport/
 sed -i '' -e 's/17A5241c/17A5241e/g' /tmp/MyMetalExport/MetalToolchain-17A5241c.exportedBundle/ExportMetadata.plist
 xcodebuild -importComponent metalToolchain -importPath /tmp/MyMetalExport/MetalToolchain-17A5241c.exportedBundle

— Ed Ford,  DTS Engineer

I am still having this issue on Beta 3, after trying the methods mentioned above. It says:

cannot execute tool 'metal' due to missing Metal Toolchain; use: xcodebuild -downloadComponent MetalToolchain

Note: the metal command line code is run in my custom Swift Package plugin like this:


let xcRunURL = URL(fileURLWithPath: "/usr/bin/xcrun")

let p = Process()

p.executableURL = xcRunURL

p.arguments = [
    "metal",
     "-c",
    "-fcikernel",
    input,
     "-o",
    airOutput,
     "-fmodules=none"
]

Still happening in Xcode 26.0 (17A321) RC

I'm also having issues on Xcode 26 RC. I somehow managed to get it to compile, though unsure what or how, but after a reboot it went back to being broken.

I'm also unable to run sudo rm -rf /System/Library/AssetsV2/com_apple_MobileAsset_MetalToolchain/, it errors saying Operation not permitted. The folder contains two .asset folders if that's anything noteworthy.

Update: after many attempts I have gotten it to work by doing the following:

  • Disable system integrity protection (boot into recovery > terminal > csrutil disable)
  • Run sudo rm -rf /System/Library/AssetsV2/com_apple_MobileAsset_MetalToolchain/
  • Enable system integrity protection (boot into recovery > terminal > csrutil enable)
  • Install the toolchain
  • Manually mount the file at /System/Library/AssetsV2/com_apple_MobileAsset_MetalToolchain/*.asset/AssetData/Restore/*.dmg

As soon as I mount it, it works. Unmounting it makes it not work again. If any engineers would want to look into why that's happening, I'd be happy to help them debug this.

Unable to compile Core Image filter on Xcode 26 due to missing Metal toolchain
 
 
Q