Why I am not on the latest swiftc after installing Xcode 11.4 and removing all other Xcode.app?

I install the latest Xcode 11.4 (downloaded from developer.apple.com) in ~/Applications, deleted the beta and Xcode 11.3. Open the newly installed Xcode, allow it to do that "Need to install components". But on the command line:

which swiftc
/usr/bin/swiftc

swiftc --version
Apple Swift version 5.1.3 (swiftlang-1100.0.282.1 clang-1100.0.33.15)
Target: x86_64-apple-darwin19.4.0

xcrun -f swift
/Library/Developer/CommandLineTools/usr/bin/swift

~/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc --version 
Apple Swift version 5.2 (swiftlang-1103.0.32.1 clang-1103.0.32.29)
Target: x86_64-apple-darwin19.4.0

So the latest swift is sitting inside my one and only ~/Applications/Xcode.app

What do I need to do to get the latest inside my Xcode.app swift available on the command line?

For some reason I just check on my MacBook, it's on 5.2 and I didn't do anything extra...

Have you try to download command line tools for Xcode 11.4 ?

No. I am not sure I need to separately download that. As I said, my MacBook got the latest, but no my iMac. I did the same on both: install Xcode 11.4 and run it.

What does xcode-select -p say? It sounds like you installed the Xcode command-line tools at some point, and the active tools are still pointing there. You can fix that with xcode-select -s xxx.

Share and Enjoy

Quinn “The Eskimo!” @ DTS @ Apple

xcode-select -p
/Library/Developer/CommandLineTools

Same for both my iMac (screw up now on 5.1.3) and MacBook (which is good on 5.2). This is the system default, right?

I did once downloaded from swift.org some version of the swift toolchain and from inside Xcode Preference/Comonents "Toolchain" tab, choose that to try something out. But I've deleted that toolchain and Xcode Preference/Components do not show the "Toolchain" tab anymore. Did this change my command line, too? I thought this only change thing inside Xcode.

How can I "reset" my system to the default state: use the latest toolchain every time some new released Xcode is installed? What I want is get /Library/Developer/CommandLineTools to update to the latest. Not use xcode-select -s ... to point to my new Xcode.app.

I had the same problem and I "fixed" it by going into Preferences for Xcode, Locations, Command Line Tools, and choosing Xcode 14 (11E146).

Since I already ran "xcode-select -s ~/Applications/Xcode.app", when I went to look at Xcode Preferences Locations, Command Line Tools, it's already pointing at "Xcode 14 (11E146)". So I quit Xcode, went on the command line, run xcode-select -r to reset back to system default. Re-open Xcode, open Xcode Preferences Locations, Command Line Tools, it's now empty, then I choose "Xcode 14 (11E146)", Xcode then ask admin password to install, just like it did when I first install new version and run it. The result is exactly the same as I manually run "xcode-select -s ~/Applications/Xcode.app": the command line toolchain is just pointing to my Xcode location. The system default copy at /Library/... is unchanged, still the old 5.1.3.

So this "fix" in Xcode Preference Locations, Command Line Tools, and choosing Xcode 14 (11E146) is just doing the same as xcode-select -s .... Try on the command line, run xcode-select -p, the result points to you copy of Xcode.app, not /Library/Developer/CommandLineTools.

I want the system default at /Library/Developer/CommandLineTools updated to the latest 5.2, not use xcode-select -s ... (or set that inside Xcode Prefs, Location ...), to point to an alternate toolchain.

Again, how to reset my iMac toolchain state to the default behavior so that my command line toolchain is at /Library/Developer/CommandLineTools and updated to 5.2 (from inside my Xcode.app)?

I try:

sudo xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates

I just want my iMac to act like my MacBook :( I rather not have to manually set my command line toolchain everytime I update to a new Xcode.