Skip to content
Latchkey

SwiftPM wrong Swift toolchain / Xcode version on the runner in CI

macOS runners ship several Xcode versions and default to one that may not match your package. If the selected Swift is wrong, SwiftPM hits tools-version, language-version, or module-build errors that all trace back to the runner toolchain.

What this error means

Builds fail with swift-tools-version, unsupported Swift version, or module mismatch errors that disappear once the correct Xcode is selected with xcode-select.

swift
$ swift --version
swift-driver version: 1.90.11 Apple Swift version 5.9 (default)
error: package at '.' is using Swift tools version 6.0.0 but the installed swift-tools-version is 5.9.0

Common causes

The runner default Xcode is older than needed

The image default Xcode ships an older Swift than your swift-tools-version or language mode requires.

No explicit toolchain selection in CI

The job relied on the default xcode-select instead of pinning a specific Xcode, so the toolchain is whatever the image chose.

How to fix it

Select the intended Xcode explicitly

  1. List installed Xcodes and pick the version your package needs.
  2. Set it with xcode-select or DEVELOPER_DIR.
  3. Verify swift --version, then build.
Terminal
sudo xcode-select -s /Applications/Xcode_16.app
swift --version
swift build

Pin the toolchain via the workflow environment

Set DEVELOPER_DIR at the job level so every step uses the same Xcode.

.github/workflows/ci.yml
env:
  DEVELOPER_DIR: /Applications/Xcode_16.app/Contents/Developer

How to prevent it

  • Pin the Xcode version instead of relying on the runner default.
  • Verify swift --version early so a wrong toolchain fails fast.
  • Keep the runner Xcode aligned with your swift-tools-version.

Related guides

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