a shell script for extract Xcode toolchain from xip file.
Download Xcode xip file from: https://developer.apple.com/download/all/
./extract-xcode-toolchain.sh Xcode_11.3.1.xip ~/Documents
Xcode 11.3.1 toolchain will saved at ~/Documents/Xcode_11.3.1.xctoolchain.tar.xz
if your Xcode.app installed at /Applications/Xcode.app
, create a directory with .xctoolchain
suffix:
mkdir /Applications/Xcode.app/Contents/Developer/Toolchains/Xcode_11.3.1.xctoolchain
extract toolchain:
tar -xvf Xcode_11.3.1.xctoolchain.tar.xz \
-C /Applications/Xcode.app/Contents/Developer/Toolchains/Xcode_11.3.1.xctoolchain
Using Xcode_11.3.1 toolchain in command line:
$ xcrun --toolchain Xcode_11.3.1 swift --version
Apple Swift version 5.1.3 (swiftlang-1100.0.282.1 clang-1100.0.33.15)
Target: x86_64-apple-darwin21.6.0
User defined toolchain is installed at /Library/Developer/Toolchains
sudo mkdir -p /Library/Developer/Toolchains/Xcode_11.3.1.xctoolchain
extract toolchain into /Library/Developer/Toolchains/Xcode_11.3.1.xctoolchain
sudo tar -xvf Xcode_11.3.1.xctoolchain.tar.xz \
-C /Library/Developer/Toolchains/Xcode_11.3.1.xctoolchain
User defined Identifier
of toolchain can't have prefix com.apple.*
, replace com.apple.dt.toolchain.Xcode_11.3.1
with Xcode_11.3.1
:
/usr/libexec/PlistBuddy -c "Set Identifier Xcode_11.3.1" ToolchainInfo.plist
User defined CompatibilityVersion
of toolchain should be 2
:
/usr/libexec/PlistBuddy -c "Add CompatibilityVersion integer 2" ToolchainInfo.plist
Now, content of ToolchainInfo.plist:
$ /usr/libexec/PlistBuddy -c "Print" ToolchainInfo.plist
Dict {
CompatibilityVersion = 2
Identifier = Xcode_11.3.1
}