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 --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.0Common 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
- List installed Xcodes and pick the version your package needs.
- Set it with
xcode-selectorDEVELOPER_DIR. - Verify
swift --version, then build.
sudo xcode-select -s /Applications/Xcode_16.app
swift --version
swift buildPin the toolchain via the workflow environment
Set DEVELOPER_DIR at the job level so every step uses the same Xcode.
env:
DEVELOPER_DIR: /Applications/Xcode_16.app/Contents/DeveloperHow to prevent it
- Pin the Xcode version instead of relying on the runner default.
- Verify
swift --versionearly so a wrong toolchain fails fast. - Keep the runner Xcode aligned with your
swift-tools-version.