How to switch xcode on Mac?
Because of the need of learning, I installed two versions of Xcode on MAC, one is Xcode 7.3, the other is Xcode 8.3. But in some cases I need to switch the version of xcode, so I find out the following experience.
1. View the current version of xcode
/usr/bin/cc --version
Here I am:
jhmdeiMac:~ jhm$ /usr/bin/cc --version
Apple LLVM version 7.3.0 (clang-703.0.29)
Target: x86_64-apple-darwin16.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
As you can see, my current version is Xcode 7.3.0
2. Switching xcode version
First look at the switch command: xcode-select
jhmdeiMac:~ jhm$ xcode-select -h
Usage: xcode-select [options]
Print or change the path to the active developer directory. This directory
controls which tools are used for the Xcode command line tools (for example,
xcodebuild) as well as the BSD development commands (such as cc and make).
Options:
-h, --help print this help message and exit
-p, --print-path print the path of the active developer directory
-s <path>, --switch <path> set the path for the active developer directory
--install open a dialog for installation of the command line developer tools
-v, --version print the xcode-select version
-r, --reset reset to the default command line tools path
Next, we use the command line to switch the xcode version.
sudo xcode-select --switch /Library/Developer/CommandLineTools
Of course, you need to know where your other xcode versions are before you order them.
Use / usr/bin/cc - version to check if the version has changed.
jhmdeiMac:~ jhm$ /usr/bin/cc --version
Apple LLVM version 8.1.0 (clang-802.0.42)
Target: x86_64-apple-darwin16.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin