How to Easily Switch Between Xcode versions

Easily move between versions of Xcode to test your code thoroughly

Jesus Nieves
Better Programming

--

Person typing on a laptop.
Photo by Fabian Irsara on Unsplash.

iOS 14 is here. If you need to install a new version of Xcode to test your application and you also need to keep the old version of Xcode for some reason, this article is for you.

Every time a new version of iOS comes out, we have to update our compiler to be able to test the new operating system of our application on a new iPhone.

I have worked on a couple of apps and the outlook is always the same: A new version of the operating system comes out and we have to update our Xcode, but our CI is configured with a previous version or maybe we have a library that is maintained by multiple developers and they use the same version of Xcode to be consistent across builds.

Regardless of the case, the solution is always to manually download all the versions we need and then pray to some god that nothing breaks with command-line build compatibility.

Is there an easier way?

The Easiest and Fastest Way

There is a tool called xcode-install that allows you to easily install and manage multiple versions of Xcode on your computer. Surely, you have heard of NVM (Node version manager) or RVM (Ruby version manager). This is something similar, but for Xcode.

Installation

Just run this in your terminal:

$ gem install xcode-install

Usage

Now it’s time to play around and start managing our Xcode versions.

List all available and installed Xcode versions:

xcversion list

Install a specific Xcode version:

xcversion install 12

Select a specific Xcode version to use:

xcversion select 12

If you want to change the symlink at /Applications/Xcode, run:

xcversion select 12 --symlink

To see the currently selected version:

$ xcversion selected

xcode-install needs environment variables with your credentials to access the Apple Developer Center. They are stored using the credentials_manager of fastlane:

XCODE_INSTALL_USER
XCODE_INSTALL_PASSWORD

And that’s it, now we can install or remove any version of xcode with a single command…

But There Is Something Else…

xcode-install can also install Xcode’s command-line tools by calling:

xcversion install-cli-tools

Did someone say, “simulators”?

xcode-install can also manage your local simulators using the simulators command:

xcversion simulators

I hope this tool can be useful to you. I call it my little XVM (Xcode version manager).

--

--

✖Member of the @xteam, 👊🏽Software Engineer at @riotgames 👨🏽‍🏫Mentor at @FrontEndCafe 📢Speaker at @fundacionjaa ✍🏼Writer at @medium