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

后端 未结 15 1236
失恋的感觉
失恋的感觉 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 17:55

    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.

提交回复
热议问题