devalias devalias - 5 months ago 31
Swift Question

Where are the swift/swiftc binaries for v3?

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?

Answer

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