How to Select an Xcode Version in GitHub Actions
macOS runners ship several Xcode versions; point xcode-select (or setup-xcode) at the exact one your build needs.
GitHub macOS images preinstall multiple Xcodes under /Applications/Xcode_<version>.app. Activate one with sudo xcode-select -s, or let maxim-lobanov/setup-xcode resolve a version range for you.
Steps
- List installed Xcodes with
ls /Applications | grep Xcode. - Switch the active toolchain with
sudo xcode-select -s /Applications/Xcode_<ver>.app. - Or add
maxim-lobanov/setup-xcodewith anxcode-versionto resolve it for you. - Verify with
xcodebuild -version.
Workflow
.github/workflows/ci.yml
jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '16.2'
- run: xcodebuild -versionPlain xcode-select alternative
.github/workflows/ci.yml
steps:
- run: sudo xcode-select -s /Applications/Xcode_16.2.app
- run: xcodebuild -version && swift --versionGotchas
- A version present on one runner image may not exist on another; check the image release notes before pinning.
- Use
xcode-version: latest-stablewith setup-xcode to track the newest GA release automatically.
Related guides
How to Build a macOS App With xcodebuild in GitHub ActionsBuild a macOS app on a GitHub Actions runner with xcodebuild build, targeting the platform=macOS destination…
How to Run iOS Tests on a Simulator in GitHub ActionsRun XCTest/XCUITest on a GitHub Actions macOS runner with xcodebuild test and a -destination that targets an…