How do I see which version of Swift I'm using?

后端 未结 15 1149
失恋的感觉
失恋的感觉 2020-11-28 17:20

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

相关标签:
15条回答
  • 2020-11-28 18:00

    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.
    
    0 讨论(0)
  • 2020-11-28 18:05

    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 :]

    0 讨论(0)
  • 2020-11-28 18:07
    /usr/bin/swiftc --version
    

    and swift version <--> Xcode version

    0 讨论(0)
提交回复
热议问题