Can I have multiple Xcode versions installed?

Viewed 116145

Is it possible to have more than one version of Xcode installed at the same time?

If so, please post any tip, tricks, or potential issues to watch out for.

EDIT:

The reason I want to install multiple versions is to try out the new sdk beta, but if the new Xcode is buggy I want to be able to use the older version for my existing projects.

13 Answers

It seems that Xcode really likes to be in the Applications folder and be called Xcode, especially when using xcodebuild (when building for Carthage for example) - and xcode-select doesn't always seem to cut it.

I have a client project that's still using Swift 2.2, and I'm stuck on Xcode 7 for that and using Xcode 8 for anything else.

So, in my Applications folder, I have Xcode 7 (renamed to Xcode_7) and Xcode 8 (renamed to Xcode_8). Then I rename whichever one I need to simply Xcode, and back again when done. It's a ball-ache, but seems to work.

This shell script simplifies it a bit…

xcode-version.sh

cd /Applications

if  [[ $1 = "-8" ]]
then 
    if [ -e Xcode_8.app ] 
    then            
        mv Xcode.app Xcode_7.app
        mv Xcode_8.app Xcode.app
        echo "Switched to Xcode 8"
    else
        echo "Already using Xcode 8"
    fi
elif  [[ $1 = "-7" ]]
then
    if [ -e Xcode_7.app ] 
    then            
        mv Xcode.app Xcode_8.app
        mv Xcode_7.app Xcode.app
        echo "Switched to Xcode 7"
    else
        echo "Already using Xcode 7"
    fi
else
    echo "usage: xcode-version -7/8"
fi

xcode-select --switch Xcode.app

Multiple Versions Of Xcode & Simulators using gem Xcode::Install

Install and update your Xcodes automatically.

You can greatly simplify this process by using the Xcode::Install Ruby Gem.

You should already have a working installation of the Xcode Command Line Tools and a version of Ruby that supports building native extensions.

I'd suggest using Homebrew for installing rbenv and use rbenv to install Ruby. A guide for this can be found here and many other places.

But it should work with the stock Ruby supplied by newer macOS versions as well, if you install the gem either using sudo (not recommended) or using --user-install when installing the gem.

Installation

Basically:

# Install the Ruby Gem (I'm using rbenv, so no sudo or --user-install)
$ gem install xcode-install

# To list available versions:
# PS!You will get prompted for your Apple Developer / iCloud credentials)
# It's using Apple's own API's so 2FA are supported if enabled

$ xcversion list
6.0.1
6.1
6.1.1
6.2 (installed)
6.3
# To update the list of available versions, run:
$ xcversion update

# To install a certain version, simply:
$ xcversion install 8

##################################################################### 100.0%
Please authenticate for Xcode installation...

Xcode 8
Build version 6D570

This should download and install and activate that version of Xcode. You can start it from /Applications as usual.

The new version will also be automatically selected for CLI commands To select a different version as active, you'll run:

xcversion select <version_number>

from the list of installed versions, marked as (installed) like:

# To see the active version in use:
$ xcversion selected

# To select and activate an installed version:
$ xcversion select 8

# To select, activate and change the symlink in /Apllications
$ xcversion select 8 --symlink

Other fun stuff, Simulators etc

Xcode::Install can also install Xcode's Command Line Tools by calling

xcversion install-cli-tools and can also manage your local simulators using the simulators command.

But instead of repeating more information that is probably going to change over time, head over to the project's GitHub page for more about this gem.

Download a version

The beta and stable releases can be taken from the Developer Software downloads Application tab, here), but older versions can be taken from here. Just extract the .xib and put Xcode-beta.app in your Applications folder.

Switch versions

  • Using the beta: sudo xcode-select -s /Applications/Xcode-beta.app/Contents/Developer
  • Using the original: sudo xcode-select -s /Applications/Xcode.app/Contents/Developer

Check version changed

You can validate the version has changed by running xed --version, and it will output the correct version: e.g. xed version 12.5 or xed version 13.0

Related