I just created a new Swift project within Xcode. I am wondering which version of Swift it\'s using.
How can I see, in Xcode or the terminal, what version of Swift I
This reddit post helped me: https://www.reddit.com/r/swift/comments/4o8atc/xcode_8_which_swift/d4anpet
Xcode 8 uses Swift 3.0 as default. But you can turn on Swift 2.3. Go to project's Build Settings and set 'Use Legacy Swift Language Version' to YES.
Good old reddit :)
From Xcode 8.3 onward Build Settings
has key Swift Language Version
with a value of swift version your target is using.
For older Xcodes use this solution, open terminal and type following command(s)
Case 1: You have installed only one Xcode App
swift -version
Case 2: You have installed multiple Xcode Apps
Switch active developer directory
(Replace Xcode_7.3.app
from
following command with your Xcode app file name from Application directory for which you want
to check swift version)
sudo xcode-select --switch /Applications/Xcode_7.3.app/Contents/Developer
Then
swift -version
NOTE: From Xcode 8 to Xcode 8.2.x you can use swift 2.3 even though Xcode 8 uses swift 3.x as default swift version. To use swift 2.3, just turn on flag Use Legacy Swift Language Version
to YES
from Build Setting
and XCode will use Swift 2.3 for that project target.
I am using Swift from Google Colab. Here's how to check it in Colab.
!/swift/toolchain/usr/bin/swift --version
The result is 5.0-dev
Updated answer for how to find which version of Swift your project is using in a few click in Xcode 12 to help out rookies like me.
You will get this under the project setting
To see the default version of swift installed on your machine then from the command line, type the following :
swift --version
Apple Swift version 4.1.2 (swiftlang-902.0.54 clang-902.0.39.2)
Target: x86_64-apple-darwin17.6.0
This is most likely the version that is included in the app store version of Xcode that you have installed (unless you have changed it).
If you want to determine the actual version of Swift being used by a particular version of Xcode (a beta, for instance) then from the command line, invoke the swift binary within the Xcode bundle and pass it the parameter --version
/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift --version
Apple Swift version 4.2 (swiftlang-1000.0.16.7 clang-1000.10.25.3)
Target: x86_64-apple-darwin17.6.0