Skip to content
Latchkey

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 PATH

Common 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

  1. List available Xcodes on the runner.
  2. Select a full Xcode app (not just Command Line Tools) with xcode-select.
  3. Re-run swift test.
Terminal
sudo xcode-select -s /Applications/Xcode_16.app
xcrun --find xctest
swift test

Set 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/Developer

How to prevent it

  • Select a full Xcode explicitly rather than relying on the image default.
  • Confirm xcrun --find xctest succeeds in an early step.
  • Pin the Xcode version so the developer directory stays valid.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →