C.W.K.
Stream
Lesson 03 of 05 · published

Setting Up on macOS

~10 min · metal, macos, xcode, setup, command-line

Level 0Beginner
0 XP0/38 lessons0/12 achievements
0/100 XP to next level100 XP to go0% complete

The terminal-only path: full Xcode + xcrun, no GUI projects required

You don't need to open Xcode. You don't need to learn the Swift Package Manager. You don't need a .xcodeproj. For compute-only Metal development, four shell commands and a Swift host file are enough.

The catch: 'Command Line Tools for Xcode' alone is not sufficient — it omits the metal compiler binary. You need full Xcode from the App Store. After installing, point macOS at Xcode's developer dir so xcrun finds the Metal toolchain.

Code

Activate Xcode's full toolchain·bash
# Install Xcode 26 from the Mac App Store (or via 'xcodes' CLI),
# accept the license, then point the system at it:
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer

# Confirm the Metal toolchain is visible:
xcrun -sdk macosx metal -v        # 'Apple metal version 32.x'
xcrun -sdk macosx metallib -h     # help text printed = linker visible
xcrun -sdk macosx swiftc -version # 'swift-driver version 1.x'
One-shot Makefile pattern for compute-only Metal·bash
# Build a kernel.metal + host.swift project from the terminal:
xcrun -sdk macosx metal -c kernel.metal -o build/kernel.air
xcrun -sdk macosx metallib build/kernel.air -o build/kernel.metallib

xcrun -sdk macosx swiftc host.swift \
    -framework Metal -framework Foundation \
    -o build/host

# Run from build/ so kernel.metallib is found relative to host.
cd build && ./host

External links

Exercise

On any Apple Silicon Mac you have, run all three verify commands above. The bar: each prints a version or help string without error. If metal is missing, install full Xcode now — every subsequent Apple-side lesson assumes it's there.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.