Swift "xcrun: error: unable to find utility 'xctest'" in CI
xcrun resolves developer tools relative to the active developer directory. When swift test cannot find xctest, the selected Xcode (or Command Line Tools) is wrong, incomplete, or not pointed at a full Xcode.
What this error means
swift test fails with "xcrun: error: unable to find utility 'xctest', not a developer tool or in PATH" on a macOS runner.
swift
xcrun: error: unable to find utility "xctest", not a developer tool or in PATHCommon causes
The active developer dir is Command Line Tools, not Xcode
Command Line Tools alone do not ship xctest; if xcode-select points there, xcrun cannot find the test tool.
The selected Xcode path is missing or wrong
A stale or non-existent DEVELOPER_DIR/xcode-select path leaves xcrun unable to resolve bundled utilities.
How to fix it
Point xcode-select at a full Xcode
- List available Xcodes on the runner.
- Select a full Xcode app (not just Command Line Tools) with
xcode-select. - Re-run
swift test.
Terminal
sudo xcode-select -s /Applications/Xcode_16.app
xcrun --find xctest
swift testSet DEVELOPER_DIR for the step
Export DEVELOPER_DIR so xcrun resolves utilities from the intended Xcode without a global switch.
.github/workflows/ci.yml
env:
DEVELOPER_DIR: /Applications/Xcode_16.app/Contents/DeveloperHow to prevent it
- Select a full Xcode explicitly rather than relying on the image default.
- Confirm
xcrun --find xctestsucceeds in an early step. - Pin the Xcode version so the developer directory stays valid.
Related guides
SwiftPM wrong Swift toolchain / Xcode version on the runner in CIFix SwiftPM failures from the wrong Swift toolchain or Xcode on a CI runner - the default selected Xcode does…
Swift "Compiling for iOS ... but module was built for ..." arch mismatch in CIFix Swift "error: Compiling for iOS X, but module was built for iOS Y" in CI - a prebuilt module or dependenc…
xcodebuild "Could not resolve package dependencies" in CIFix xcodebuild "error: Could not resolve package dependencies" in CI - Xcode's integrated SPM resolution fail…