Skip to content
CoreMacs
XcodeGuide

Running several Xcode versions side by side on one Mac

Teams rarely move every project to a new Xcode on the same day. This guide shows how to keep several versions on one Mac, switch between them safely, pin one per project or CI job, and prepare each copy for unattended use.

CoreMacs News Desk·Published ·Last verified ·5 min read
Two silver Mac mini computers on a wooden table, one standing upright and one lying flat, against a blue-purple background.

Most teams that ship Apple software end up needing more than one Xcode. A release branch may be frozen on the toolchain that shipped it, while the main branch tries a newer one, and a beta needs a place to live without disturbing either. Xcode supports this well, but the switching rules are easy to get wrong, and the wrong Xcode can quietly build your app. This guide covers the mechanics.

Installing more than one copy

Xcode is a self-contained app bundle. Installing a second version is mostly a matter of not letting it overwrite the first. Download the version you need from Apple's developer downloads, expand it, and rename the app so the version is visible, for example Xcode-A.app and Xcode-B.app with the real version numbers in the names. Many teams keep them under /Applications or a dedicated folder such as /Applications/Xcodes; either works, because the tools follow the active developer directory rather than a hard-coded path.

Keep in mind that each copy is large, and simulators and platform support add more. Plan disk space before you plan versions, and remove the ones nobody builds with any more.

Switching the default with xcode-select

The command-line shims in /usr/bin, such as xcodebuild and clang, run the copy found in the active developer directory. According to the man page, xcode-select sets that directory for every user on the machine and needs superuser rights. You can pass either the app path or its Contents/Developer folder.

sudo xcode-select --switch /Applications/Xcode-B.app
xcode-select --print-path
xcodebuild -version

Use --print-path to see what is selected, and --reset to remove a custom choice and return to the default search. The man page also advises scripts to locate tools with xcrun instead of parsing the printed path, which keeps them correct when Xcode is installed somewhere unusual.

Pinning a version with DEVELOPER_DIR

A machine-wide switch is a poor fit for shared machines, because it changes the result for everyone and every job. The DEVELOPER_DIR environment variable overrides the system setting for the current process and needs no sudo.

export DEVELOPER_DIR=/Applications/Xcode-A.app/Contents/Developer
xcodebuild -version

# or for one command only
env DEVELOPER_DIR=/Applications/Xcode-B.app/Contents/Developer xcodebuild -version

This is the safest way to pin a version. Put the export at the top of a build script, in a per-project environment file, or in the environment section of a CI job. Print xcodebuild -version early in every job so the log records which toolchain actually ran.

Preparing a copy for unattended use

A fresh Xcode normally asks you to accept the licence and install extra components on first launch. On a build machine nobody is there to click. The xcodebuild man page documents three options for this:

  • -license lets you accept the licence agreements without launching Xcode, which suits headless systems. It must be run as a privileged user.
  • -runFirstLaunch installs the additional system components and agrees to the licence.
  • -checkFirstLaunchStatus exits with a non-zero status when more content needs to be installed, and with zero when components are current, so scripts can use it as a gate.
sudo xcodebuild -license
sudo xcodebuild -runFirstLaunch
xcodebuild -checkFirstLaunchStatus; echo $?

Note that -license is listed on the man page without a value. Some provisioning scripts append an accept argument; that form is common practice rather than something the man page shows, so check it before relying on it. Test the whole sequence on each Xcode version you provision: run it, then run a trivial build as a non-admin user and confirm that no prompt appears. Platform runtimes, such as simulators, may need their own download step, so confirm that on your setup as well.

The xcodes command-line tool

If you manage many versions, the open-source xcodes tool automates the routine. According to its project page it is MIT licensed, installs through Homebrew, and offers list for available versions, installed for local ones, install, select and uninstall. The version number below is only a syntax example taken from the project page; run xcodes list to see what is currently available.

brew install xcodesorg/made/xcodes
xcodes list
xcodes install 10.2.1
xcodes select 10.2.1

Downloads need an Apple ID. The project page says you are prompted, or you can set XCODES_USERNAME and XCODES_PASSWORD, after which the password is stored in the keychain. That has security consequences on shared or automated machines, so decide deliberately where credentials live. If aria2 is installed, xcodes uses it for faster downloads. The project page does not describe first-launch handling, so keep your own provisioning step for that.

Which Xcode runs on which macOS

Do not guess compatibility. Apple publishes an SDKs and system requirements table that lists, per Xcode version, details such as the supported macOS versions and bundled SDKs. Check it for the exact columns it offers today. A host on one macOS release may not be able to run both the newest and the oldest toolchain you need, so check the table before upgrading macOS on a build host, and read the Xcode release notes for known issues and changes in each release.

A practical checklist

  • Name each app bundle with its version.
  • Pin the toolchain with DEVELOPER_DIR in every project script and CI job.
  • Log xcodebuild -version at the start of each build.
  • Provision licence and first-launch steps once per version and test them as a normal user.
  • Re-read the requirements table before any macOS upgrade.

Sources

Share