Working with Multiple Versions of Xcode
Using the Mac App Store version of Xcode is the simplest way to keep up to date. Depending on your App Store settings in System Preferences, apps will update automatically or the OS will prompt you when updates are available.
If using the latest version was always the best thing to do, life would be simple.
Life is Not That Simple!
The version of Xcode you use to build your app has a number of important consequences.
- It sets the base SDK version that you are building against. This can implicitly opt you in to certain OS features. For example, building against the iOS 10 SDK in Xcode 8.x opts your app in to the new Today Widget appearance. Build with Xcode 7.x (against the iOS 9 SDK) and even when run on iOS 10, your app will use the iOS 9 style widgets.
- For Swift code, the version of the language itself can change. This was particularly important during the Swift 2.x to 3.0 timeframe when the language underwent many significant, and incompatible, changes. Still using Swift 2.3? You can’t use Xcode 8.3 or higher.
- Support for older OS versions. Xcode is quite aggressive at dropping simulator support for older iOS versions. If you want simulator support for more than the current and previous major iOS version, you often can’t use the latest Xcode release.
- Xcode betas. At the time of writing, WWDC 2017 is about to start. If you want to start testing against beta OS versions or take advantage of new APIs, you’re going to need to use a beta version of Xcode. You can’t release app updates built with a beta version of Xcode.
Having multiple versions of Xcode available provides more flexibility. It’s good practice to try and stay up-to-date, but sometimes you need the ability to release an app built with an older version. This is especially important just after the public release of a major iOS version around September if your app isn’t quite ready to opt in to all the new features but you need to release an update.
Installing Multiple Versions of Xcode
For the most flexibility, the best approach is to download specific versions of Xcode manually rather than using the Mac App Store version. Apple provides download links for released versions of Xcode on its website at https://developer.apple.com/download/more/. Between WWDC and public release, the latest beta version of Xcode can be downloaded from https://developer.apple.com/download/. The link on that page for the current version just opens the Mac App store. It’s best to use the manual download. Sometimes it takes a little while for the most recent public release to become available for manual download.
Installing a specific version is easy.
Xcode 8 and later (.xip):
- Download. Download the .xip file.
- Unarchive. Double click the .xip file in your Downloads folder to unarchive it.
Xcode 7 and earlier (.dmg):
- Download. Download the .dmg file.
- Install. Double click on the .dmg file. The installer suggests dragging Xcode.app to the Applications folder. If you already have an Xcode.app in /Applications (perhaps the Mac App Store version), don’t do that. Instead, drag it to your desktop.
Once you have an Xcode.app file:
- Rename. Rename the Xcode.app file to include the version number (e.g. “Xcode8.3.2.app”) to identify the version and to set a unique filename. Downloads of beta versions of Xcode already have a unique name and this step is not required (unless you prefer to use an alternate name).
- Move to /Applications. Drag the file to your Applications folder.
Only after the Xcode version has been renamed and moved to /Applications is it safe to launch it. Moving its location afterwards can cause problems. On first launch, Xcode sometimes prompts to install command line tools. It’s easiest to just let Xcode do that.
Repeat this process for each version of Xcode you want to install. Over time, you’ll build up a few versions and can remove those you no longer need. Xcode is a big app and uses a lot of disk space.
Command Line Tools
Developers with more complex build processes prefer to build from the command line. In more recent versions of Xcode, choosing which version of the command line tools to use can be done from the Locations tab in Xcode’s Preferences window:
Alternatively, the xcode-select command line tool can be used to view or select which version of the Xcode tools are being used:
$ sudo xcode-select -s /Applications/Xcode9b1.app/Contents/Developer
$ xcode-select -p
Launching different Xcode Versions
Xcode really does not like being run multiple times. Be sure to quit Xcode and the simulator before launching a different version.
To check which version of Xcode you are currently running, open Xcode’s About menu:
Use Finder to double click on a specific Xcode version in the Applications folder or choose the correct version from a Spotlight search. Be careful: Spotlight will sometimes adjust the order it presents the different versions to you!
Alternatively, one of the features of my xcLauncher menu bar app is to launch a specific version of Xcode:
xcLauncher’s main feature is to provide bookmarks for your favorite Xcode projects, workspaces and playgrounds right from the system menu bar. For more information take a look at my web site or view it in the Mac App Store.