Xcode 27.2: metal-package-builder Cannot Locate coremlcompiler When Converting .mlpackage to .mtlpackage

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.

  1. metal-package-builder is located inside the separately installed Metal Toolchain:
.../Metal.xctoolchain/usr/bin/metal-package-builder
  1. coremlcompiler does exist, but it is located inside Xcode's default toolchain:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/coremlcompiler
  1. The Metal Toolchain directory does not contain coremlcompiler or an XcodeDefault.xctoolchain directory.

  2. Conversely, Xcode's default toolchain contains coremlcompiler, but does not contain metal-package-builder or coreai-build.

  3. xcrun can successfully locate the relevant tools individually. In other words, the tools are installed and discoverable, but metal-package-builder appears to be looking for coremlcompiler in 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 xcrun can locate metal-package-builder and coremlcompiler individually.
  • Tried changing TOOLCHAINS and DEVELOPER_DIR to influence toolchain selection, but the error remains.
  • Inspected the metal-package-builder binary and found a reference to the relative path XcodeDefault.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

  1. Is this an issue with the Xcode 27.2 / Metal Toolchain 27B47 installation, or is metal-package-builder expected to locate coremlcompiler using this relative path?
  2. Is there a supported way to make metal-package-builder use the coremlcompiler executable from Xcode's default toolchain?
  3. Is there a required toolchain configuration, environment variable, or installation step that I may have missed?
  4. 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.