Hi, This is the information I compiled from the helpful people at SackOverflow.
The Following I have verified with my screenshots.
Determine the version of swift.
First Make Sure Command Line Tools are installed
Xcode -> Preferences -> Locations

$ xcrun swift -version

$ xcrun –find swift
and look at the path to Xcode that it shows you. For example:

You can also use xcode-select -p to
print the path to the Xcode that xcrun will use,
and sudo xcode-select -s /path/to/Xcode.app to change it. –

Project ► (Select Your Project Target) ► Build Settings ►
(Type ‘swift_version’ in the Search bar) Swift Compiler Language ►
Swift Language Version ► Click on Language list to open
it (and there will be a tick mark on any one of list-item,
that will be current swift version).

Terminal: Different commands to see version
Open the Terminal and write:
swift -version
swift -v
/usr/bin/swiftc –version
swift help for assistance.

Switch active developer directory
sudo xcode-select –switch /Applications/Xcode_7.3.app/Contents/Developer

From here on I haven’t been able to verify yet.
From Xcode 8.3 onward Build Settings has key Swift Language Version
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 Language Version doesn’t come up as a setting in my Xcode 8.2.1 project. It does have Use Legacy Swift Language Version.
Swift Language Version didn’t exist here in Build Settings until Xcode 8.3….
in prior Xcode 8.x versions Use Legacy Swift Language Version,No = Swift 3, and Yes = Swift 2.3
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).
actual version of Swift being used by a particular version of Xcode
/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
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.
Swift version based on Xcode Version:
Xcode 12.5 : Swift version 5.4.2
Xcode 12.3 : Swift version 5.3.2
Xcode 12.2 : Swift version 5.3.1
Xcode 11.6 : Swift version 5.2.4
Xcode 11.5 : Swift version 5.2.4
Xcode 11.4 : Swift version 5.2
Xcode 11.3 : Swift version 5.1.3
Xcode 11.2.1 : Swift version 5.1.2
Xcode 11.1 : Swift version 5.1
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift –version
run code for a particular version of swift
#if compiler(>=5.1) //4.2, 3.0, 2.0 replace whatever swft version you wants to check
#endif
version of Swift your project in Xcode 12
Click on your Project (top level Blue Icon in the left hand pane)
Click on Build Settings (5th item in the Project > Header)
Scroll down to Swift Compiler – Language, and look at the dropdown.
UPDATE WWDC 2015 – Swift 2.0
As stated in Apple’s Swift blog, in Swift 2.0 we have
#available blocks to check for certain OS versions in our code.
if #available(OSX 10.11, *) {
monochromeFilter!.setValue(CIColor(red: 0.5, green: 0.5, blue: 0.5), forKey:kCIInputColorKey)
} else {
// Fallback on earlier versions
}
Links I found From StackOverflow
How do I see which version of Swift I’m using? – StackOverflow
How can I programmatically find Swift’s version? – StackOverflow
What versions of Swift are supported by what versions of Xcode? – StackOverflow
Swift Version Checker – Github
Compiler Version Directive – GitHub