A GitHub Action that selects the desired Xcode version using xcode-select with improved logging and validation.
- ✅ Smart validation - Validates Xcode availability before switching
- ✅ Efficient execution - Skips execution if already using correct version
- ✅ Enhanced logging - Improved error handling with emoji indicators
- ✅ Helpful diagnostics - Lists available Xcode versions on failure
- ✅ Robust error handling - Comprehensive error checking and reporting
- name: Setup Xcode
uses: andredestro/setup-xcode-version@v1
with:
xcode-version: '26.2'| Input | Description | Required | Default |
|---|---|---|---|
xcode-version |
The Xcode version to select (e.g., 26.2, 16.4) | Yes | - |
| Output | Description |
|---|---|
previous-version |
The Xcode version that was previously selected |
current-version |
The Xcode version that is now selected |
name: iOS Build
on: [push, pull_request]
jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Setup Xcode 26.2
uses: andredestro/setup-xcode-version@v1
with:
xcode-version: '26.2'
- name: Build iOS App
run: xcodebuild build -project MyApp.xcodeproj -scheme MyAppname: Multi-Xcode Test
on: [push, pull_request]
jobs:
test:
runs-on: macos-latest
strategy:
matrix:
xcode-version: ['16.4', '26.1.1', '26.2']
steps:
- uses: actions/checkout@v4
- name: Setup Xcode ${{ matrix.xcode-version }}
uses: andredestro/setup-xcode-version@v1
with:
xcode-version: ${{ matrix.xcode-version }}
- name: Run Tests
run: xcodebuild test -project MyApp.xcodeproj -scheme MyApp- name: Setup Xcode
id: setup-xcode
uses: andredestro/setup-xcode-version@v1
with:
xcode-version: '26.2'
- name: Show Version Info
run: |
echo "Previous version: ${{ steps.setup-xcode.outputs.previous-version }}"
echo "Current version: ${{ steps.setup-xcode.outputs.current-version }}"🔍 Checking current Xcode configuration...
📍 Current Xcode path: /Applications/Xcode_16.4.app/Contents/Developer
🔍 Checking if Xcode 26.2 is available...
🔧 Setting Xcode version to 26.2...
✅ Successfully set Xcode to version 26.2
📍 New Xcode path: /Applications/Xcode_26.2.app/Contents/Developer
xcode-select version 2397.
- Runners: macOS runners only (macos-latest, macos-14, etc.)
- Xcode: Target Xcode version must be pre-installed on the runner
- Permissions: The action requires sudo access for xcode-select
If the specified Xcode version is not found, the action will:
- ❌ Display a clear error message
- 📋 List all available Xcode versions
- 🚫 Fail the workflow with exit code 1
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
If you encounter any issues or have questions:
- Check the GitHub Issues
- Create a new issue with detailed information about your problem
- Include the action logs and your workflow configuration