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
By just entering swift command in the terminal, it will show the version, while logging to Swift console.(something like below)
System-IOSs-MacBook-Air:~ system$ swift
Welcome to Apple Swift version 5.1 (swiftlang-1100.0.270.13 clang-1100.0.33.7).
Type :help for assistance.
Bonus contribution: I'm using a custom node.js script to extract a clean string for use with Jazzy documentation. You might get some use of this if you can find a place to work it into your dev process:
Invoked from a Bash script:
#!/bin/bash
swiftversion=$(node SwiftVerSlicer.js "${xcrun swift -version}");
echo $swiftversion
SwiftVerSlicer.js:
// begin script
const inputString = `${process.argv[2]}`
let searchTerm = (inputString.indexOf('(') - 1)//-1 cause whitespace
let version = inputString.slice(0,searchTerm)
console.log(version)
// end script
You can also use regex of course, but do whatever you like :]
/usr/bin/swiftc --version
and swift version <--> Xcode version