I recently ran into an issue in Xcode where I downloaded a sample repository for a project, and followed the instructions listed in the repository’s README file. Only to find out that one of the included libraries was built using a prior version of Swift then the version installed with my version of Xcode. That’s really frustrating considering that maintaining multiple versions of Xcode can be quite a pain, as with maintaining multiple copies of anything.
The good news is, instead of having to try and maintain multiple versions of Xcode, we can use something called Xcode toolchains. You can download a prior version of Swift, and then install it on macOS as an administrator, and then after restarting Xcode, if it was open, will then have a new menu option to switch toolchains.
First step is to visit https://swift.org/download/#releases and choose the version of Swift you want, click the
Toolchain link to download the package, then install it on macOS (OSX). After installation is complete, you can open Xcode, restarting first if need be, and then clicking on Xcode menu option, and there should now be a
Toolchains menu option as seen in screenshot below.
After selecting your desired toolchain, you can now build those projects whose dependent libraries were built using another version of Swift than your current version of Xcode came preinstalled with!
You can also find the different toolchains under
Xcode > Preferences > Components if you wish to remove it. Hope this helps someone like it helped me!
If you found this article to be of help, please don’t forget to give as many claps as you believe it should have, and follow my blog if you are interested in seeing more like it!