young
(rtSwift)
1
Installed Xcode-beta 11.4, how can I see what version of swiftc it's using?
xcode-select only control what the command line uses, right? This is independent of what's inside Xcode?
You can run swiftc -version in terminal and it will print the compiler version.
(Make sure you’ve selected Xcode 11.4 beta as default via xcode-select otherwise you’ll have to pass the full path to swiftc)
1 Like
young
(rtSwift)
3
swiftc -version
Apple Swift version 5.1.3 (swiftlang-1100.0.282.1 clang-1100.0.33.15)
So this is the command line version. But what's inside Xcode-beta 11.4? I think it's 5.2, but anyway to verify?
dave256
(Dave Reed)
4
It appears you didn't follow the suggestion of @suyashsrijan and use Xcode-select.
You can use the full path which on my machine is:
/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc --version
and it reports:
Apple Swift version 5.2 (swiftlang-1103.0.22 clang-1103.0.22)
Target: x86_64-apple-darwin19.3.0
1 Like
A shorter way to do what Dave Reed suggested without trying to find the full path would be
$ DEVELOPER_DIR="/Applications/Xcode-Beta.app" xcrun swiftc -version
This avoids mutating global state which is what xcode-select does.
1 Like
young
(rtSwift)
6
@dave256 @typesanitizer @suyashsrijan
Sorry, let me see if I can ask again more clearly: I don't care what my command line swiftc version is. I want to know what swiftc version is inside Xcode, which is Xcode-beta 11.4 running right now.
The commandline I gave takes that into account
. Try running it, you should see a different result than what you saw earlier:
// Old, commandline version
$ swiftc -version
Apple Swift version 5.1.3 (swiftlang-1100.0.282.1 clang-1100.0.33.15)
// New, in Xcode Beta
$ DEVELOPER_DIR="/Applications/Xcode-Beta.app" xcrun swiftc -version
Apple Swift version 5.2 (swiftlang-1103.0.22 clang-1103.0.22)
Target: x86_64-apple-darwin19.3.0
The output of my command (or Dave's) will give you the exact version being used inside the Xcode Beta.
Lantua
8
The fact that it is inside Xcode app’s content looks enough to be of Xcode origin to me.
young
(rtSwift)
9
I get it now. I ran:
~//Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc --version
Apple Swift version 5.2 (swiftlang-1103.0.22 clang-1103.0.22)
So that's the way to know what's inside Xcode.
I tried this way:
DEVELOPER_DIR="~/Applications/Xcode-beta.app" xcrun swiftc --version
xcrun: error: missing DEVELOPER_DIR path: ~/Applications/Xcode-Beta.app
I had to give it the full path:
DEVELOPER_DIR="/Users/young/Applications/Xcode-beta.app" xcrun swiftc --version
Apple Swift version 5.2 (swiftlang-1103.0.22 clang-1103.0.22)
Wonder why it doesn't like "~"?
jonprescott
(Jonathan Prescott)
10
It's bash or zsh, not xcrun. "~" doesn't get expanded in environment variables. You need to use $HOME, which points at your home directory. Nothing to do with Swift. All to do with the shell.
DEVELOPER_DIR="$HOME/Applications/Xcode-beta.app" xcrun swiftc --version
if you printenv HOME, you should see /Users/young
young
(rtSwift)
11
I’m just using the Catalina default, which is zsh.
ls ~
Works as expected. I’ll just use $HOME then.
Thanks!
jonprescott
(Jonathan Prescott)
12
ls ~ is fine, the shell expands '~' as part of the command line expansion as documented in man zsh. However, when you setup an environment variable
DEVELOPER_DIR=~
the tilde does not get expanded as part of the environment variable evaluation. That's why you need another environment variable $HOME, which is set up during login when evaluating an environment variable like DEVELOPER_DIR.
3 Likes
This is super helpful - thank you!