Managing Multiple Xcode Versions
Use the Xcodes CLI to install and switch between multiple Xcode versions with ease.
As a mobile developer, you’ve probably encountered the need to use different versions of Xcode at various stages of development. Maybe you’re using the latest version to test new features and APIs while maintaining an older, more stable version for App Store releases. Keeping multiple versions of Xcode manually can be cumbersome, but Xcodes—a powerful command-line tool—makes it easier to install, manage, and switch between different versions of Xcode with just a few commands.
In this blog, I’ll walk you through how to manage Xcode versions step by step using Xcodes.
Why Do You Need Multiple Xcode Versions?
With every new release of xCode, new features and APIs are introduced that allow you to leverage the latest in iOS development. However, App Store guidelines may require you to submit apps using a stable version, which can sometimes be a few versions behind the latest. Additionally, compatibility with certain projects or third-party libraries might necessitate keeping older versions around.
To avoid the hassle of manually downloading and managing Xcode versions, Xcodes makes this process effortless.
Installing Xcodes
Before we dive into the usage, you need to install Xcodes. The easiest way is using Homebrew (recommended):
- Open Terminal.
Run the following command:
1
brew install xcodesorg/made/xcodes
That’s it! This installs the Developer ID-signed and notarized release builds of Xcodes, meaning it doesn’t even require Xcode to be pre-installed.
Other methods (for advanced users) include:
- Downloading a release
- Using Mint
- Building from source
Step-by-Step Guide to Using Xcodes
Once Xcodes is installed, managing Xcode versions is straightforward. Here’s how to get started:
1. Install a Specific Version of Xcode
You can install a specific version of Xcode by running a simple command:
1
xcodes install 15.4
Want a beta version?
1
xcodes install 16.0 Beta 6
If you have a pre-downloaded Xcode archive, you can install it like this:
1
xcodes install 16.0 --path ~/Archive/Xcode_16.xip
2. Authenticate with Apple ID
After running an install command, you’ll be prompted to enter your Apple ID. For convenience, Xcodes can store this information securely in your keychain for future use. You can set your Apple ID using environment variables:
1
2
export XCODES_USERNAME="your-email@example.com"
export XCODES_PASSWORD="your-password"
Once authenticated, Xcodes will begin downloading and installing your specified Xcode version.
3. Switching Between Xcode Versions
With Xcodes, switching between installed versions is just as easy:
1
xcodes select 15.4
This command will switch your active Xcode version to 15.4. You can list all installed versions with:
1
xcodes installed
Need to switch often? No problem! Just use the select command to change to the version you need for your project or testing.
4. Updating Xcodes
Whenever a new version of Xcode is released, you can update the list of available versions with:
1
xcodes update
Then, install the latest version with:
1
xcodes install --latest
This keeps you up to date with the most current release, without needing to manually search for and download it.
5. Uninstalling Unwanted Xcode Versions
Once you’re done with a particular version, you can easily uninstall it:
1
xcodes uninstall 15.4
This removes the specified version from your system, freeing up disk space.
Pro Tip: Faster Downloads with aria2
By default, Xcodes uses Apple’s standard download mechanism, which works well. However, if you want to speed up the download process, you can install aria2 to leverage multiple download connections:
1
brew install aria2
Once installed, Xcodes will automatically use it for downloads, making the process 3-5x faster.
Managing Runtimes with Xcodes
Besides managing Xcode versions, Xcodes allows you to handle iOS simulator runtimes. For example, to list all available runtimes (including beta versions), run:
1
xcodes runtimes --include-betas
You can then install a specific runtime like this:
1
xcodes runtimes install "iOS 16.1-beta1"
.xcode-version File for CI
For teams and CI/CD pipelines, it’s a good idea to use a .xcode-version
file that specifies the Xcode version to use for a project. This ensures consistency across development environments and CI systems. Create this file with the desired version number:
1
16.0
Your build scripts or CI system can then automatically switch to the correct Xcode version.
Conclusion
Using Xcodes simplifies the process of installing, switching, and managing multiple versions of Xcode. Whether you’re testing beta features, submitting apps to the App Store, or managing different projects that require various Xcode versions, this tool makes it painless. Just a few terminal commands, and you’re ready to go!
So, if you’re tired of manually handling Xcode versions, give Xcodes a try—you’ll wonder how you ever managed without it.
Now you’re ready to ship your apps with the confidence that you’re always using the right version of Xcode!