Hello,
I'm trying to convert a Core ML model package (.mlpackage) into a Metal model package (.mtlpackage) using xcrun metal-package-builder, but the conversion consistently fails because metal-package-builder cannot locate coremlcompiler.
Environment
- Mac: Mac mini with Apple M2
- macOS: 27.2.1
- Xcode: 27.2 (Build 27B52)
- Metal Toolchain: 27B47
- Architecture: Apple Silicon (arm64)
Command
I'm running the following command in Terminal:
xcrun --sdk macosx --find metal-package-builder
It successfully locates metal-package-builder in the installed Metal Toolchain.
Then I run:
"$(xcrun --sdk macosx --find metal-package-builder)" \
-ml "./2x_AniSD_DC_SPAN_92500_fp16_720x480.mlpackage" \
-o "./2x_AniSD_DC_SPAN_92500_fp16_720x480.mtlpackage"
Error
The command fails with:
error: could not find coremlcompiler at
/private/var/run/com.apple.security.cryptexd/mnt/com.apple.MobileAsset.MetalToolchain-v27.2.47.0.liDqLQ/XcodeDefault.xctoolchain/usr/bin/coremlcompiler
What I have investigated so far
I checked the actual locations of the relevant executables on my system.
metal-package-builderis located inside the separately installed Metal Toolchain:
.../Metal.xctoolchain/usr/bin/metal-package-builder
coremlcompilerdoes exist, but it is located inside Xcode's default toolchain:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/coremlcompiler
-
The Metal Toolchain directory does not contain
coremlcompileror anXcodeDefault.xctoolchaindirectory. -
Conversely, Xcode's default toolchain contains
coremlcompiler, but does not containmetal-package-builderorcoreai-build. -
xcruncan successfully locate the relevant tools individually. In other words, the tools are installed and discoverable, butmetal-package-builderappears to be looking forcoremlcompilerin a different location from where it is actually installed.
Troubleshooting already attempted
- Verified that Xcode 27.2 is selected using
xcode-select. - Verified that the Metal Toolchain is installed.
- Confirmed that
xcruncan locatemetal-package-builderandcoremlcompilerindividually. - Tried changing
TOOLCHAINSandDEVELOPER_DIRto influence toolchain selection, but the error remains. - Inspected the
metal-package-builderbinary and found a reference to the relative pathXcodeDefault.xctoolchain/usr/bin/coremlcompiler.
I have also spent considerable time troubleshooting this with AI assistants, including Gemini and ChatGPT, but none of the suggested solutions has resolved the issue.
My questions
- Is this an issue with the Xcode 27.2 / Metal Toolchain 27B47 installation, or is
metal-package-builderexpected to locatecoremlcompilerusing this relative path? - Is there a supported way to make
metal-package-builderuse thecoremlcompilerexecutable from Xcode's default toolchain? - Is there a required toolchain configuration, environment variable, or installation step that I may have missed?
- If this is a bug in the current toolchain, is there a workaround or a known fix?
I would particularly appreciate clarification on the expected toolchain layout and how metal-package-builder is supposed to resolve the location of coremlcompiler.
Thank you for your help.