I've just downloaded the Xcode 8 beta, and am struggling to figure out where the swift
and swiftc
binaries are hidden.
The Swift website says that the toolchain should be available at /Library/Developer/Toolchains
and that it can be exported for use on command line with:
$ export PATH=/Library/Developer/Toolchains/swift-latest.xctoolchain/usr/bin:"${PATH}"
But that path doesn't seem to exist for me.
I can see Xcode-beta.app/Contents/Developer/Toolchains/Swift_2.3.xctoolchain
, but that's for 2.3 rather than 3.
Any ideas?
Thanks to Marc B's suggestion:
⇒ find / -name swift -type f
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift
/Users/myusername/Desktop/Xcode-beta.app/Contents/Developer/Toolchains/Swift_2.3.xctoolchain/usr/bin/swift
/Users/myusername/Desktop/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift
/usr/bin/swift
Which for me are:
⇒ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift --version
Apple Swift version 2.2 (swiftlang-703.0.18.8 clang-703.0.31)
Target: x86_64-apple-macosx10.9
⇒ /Users/myusername/Desktop/Xcode-beta.app/Contents/Developer/Toolchains/Swift_2.3.xctoolchain/usr/bin/swift --version
Apple Swift version 2.3 (swiftlang-800.10.6 clang-800.0.24.1)
Target: x86_64-apple-macosx10.9
⇒ /Users/myusername/Desktop/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift --version
Apple Swift version 3.0 (swiftlang-800.0.30 clang-800.0.24)
Target: x86_64-apple-macosx10.9
⇒ /usr/bin/swift --version
Apple Swift version 2.2 (swiftlang-703.0.18.8 clang-703.0.31)
Target: x86_64-apple-macosx10.9
To set v3 as your 'main' swift, you can do the following (make sure to use the right path to your Xcode 8 application):
⇒ sudo xcode-select -s /Applications/Xcode-beta.app/Contents/Developer
⇒ xcrun --find swift
/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift
⇒ swift --version
Apple Swift version 3.0 (swiftlang-800.0.30 clang-800.0.24)
Target: x86_64-apple-macosx10.9
As Arsen notes in Run Swift 3 from command line using Xcode 8 Beta, you can also change the settings through the Xcode menu directly. Just follow Xcode > Preferences > Locations > Command Line Tools. Then switch the drop down list from Xcode 7.3.1 to Xcode 8.0. Then enter your password for admin privileges. However, for scripting, xcode-select
is the most useful answer.
http://i.stack.imgur.com/Nzi3q.png