Installing multiple Xcode versions with xcversion
Published on: December 18, 2019As a developer that uses Xcode on a daily basis for multiple projects, you sometimes need to use different versions of Xcode depending on the project you’re working on. Or maybe you want to try out the latest Xcode beta, for example right after Apple announced it after WWDC. One way to manage is to go to the Apple developer portal, searching for the version you need and download it. You download the .xip
file, expand it (eventually, it takes a while) and then you can finally open Xcode. But then you realize you also have to rename it before dragging it to your Applications folder and when you open Xcode you have to install all the required tooling. Not the best experience.
Luckily there is an alternative available; xcode-install or xcversion
. This tool is a command-line interface that you can use to install, uninstall and manage multiple Xcode versions. Let’s look at a step by step guide to installing this tool, and using it.
Installing the xcversion command-line tool and exploring the available Xcode versions
gem install xcode-install
This command installs the command-line tool. Once it’s installed you can fetch the currently available list of Xcode versions as follows:
xcversion list
# a bunch of old versions
10.3 (installed)
11
11.1
11.2
11.2.1 (installed)
11.3 beta
Installing a new Xcode version
Note that this tool also detects what Xcode versions you have installed already. Looks like there’s a new beta available, so let’s install that:
xcversion install 11.3
This will download Xcode 11.3 Beta from the developer portal, extract the .xip
archive, copy a renamed version to our Application directory and even install Xcode’s tooling for this version. Really nice.
Activating an installed Xcode version
Since I like living on the edge, let’s make 11.3 Beta the currently active/preferred Xcode version on my machine:
xcversion select --symlink 11.3
This will run the xcode-select
utility to make sure that all of my command-line tools now use the Xcode 11.3 toolchain. It also creates a symlink called Xcode in the Applications directory so whenever you open Xcode without any version behind it, it will automatically open the currently active Xcode version.
Note
For the symlink to work properly, make sure you don’t already have an existing Xcode installation called "Xcode".⚠️ Warning
When using a dependency manager like Carthage it’s extremely important that you use the select command to activate the Xcode version you want to use when pulling down dependencies and developing your app. Having a mismatch between the Xcode version you’re developing in and the Xcode version that’s active on the command line can lead to broken builds and non-functional dependencies.
Uninstalling a no longer needed Xcode version
In the list output from before, xcversion
showed that I still had Xcode 10.3 installed. I don’t need that anymore so let’s uninstall that:
xcversion uninstall 10.3
This command works exactly as you would expect.
In summary
Juggling several Xcode versions on your machine can be frustrating. Using a tool like xcversion
makes it much easier to manage your Xcode installations, and gives you a lot of control over what Xcode version should be your default.
It also has the added benefit of not automatically updating your Xcode, just like the App Store does. I have personally lost too many hours looking for problems only to find out that the App Store had updated my Xcode to one that came with a new Swift version without my knowledge. Having full control over my Xcode installations feels liberating.
If you have any questions, feedback or anything else for me make sure to reach out on Twitter