Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I update swift from 3.1 to 3.2, but not to 4.0

I have checked the question related to how to find the current Swift version by the command swift --version, but how can I upgrade my Swift version from 3.1 to 3.2? (because the Xcode 9 only supports Swift 4.0 & Swift 3.2)

To build successfully both in Xcode 8 & Xcode 9, it's better to upgrade Swift from 3.1 to 3.2. But how?

My target was to make sure build successfully both in Xcode 8 & Xcode 9, So that publish with Xcode 8 would be OK, and try out the feature of Xcode 9 is OK too. So I will not upgrade code to swift 4.0 yet until Xcode 9.0 official edition is published.

After my test, I can't convert my code from swift 3.1 to 3.2 by Xcode 8.3.3's 'edit->convert' function.

enter image description here

The reason why I try to convert the code to Swift 3.2 is that I will get error of "Module compiled with Swift 3.1 cannot be imported in Swift 4.0" if I build the code with Xcode 9.

enter image description here

like image 243
JerryZhou Avatar asked Jun 08 '17 09:06

JerryZhou


People also ask

How do I update my Swift 3 to Swift 4?

Go to project navigator> Build Settings. search for swift Compiler - Language and change this to desired version.

How do I change the version of Swift?

Switching Swift Toolchain It can be done using Xcode, Go to Xcode->Preferences->Components-> Toolchains section and Select the Swift. 3.1. 1 snapshot, this will set the new Swift version for the local Xcode. You may need to restart Xcode.

How do I change the Swift version in Xcode?

You can find the Toolchains menu under Xcode menu, where you can easily switch between installed Swift toolchains. Toolchains menu.

How do I switch from Swift 3 to Swift 5?

You need to redownload Xcode 10.1 from this page, convert your code to Swift 4, then redownload Xcode 10.2 and convert to Swift 5.


1 Answers

You can try this:

  • Build Settings -> Swift Langauge Version -> Swift 3.2.

enter image description here

  • Edit -> Convert -> To Current Swift Syntax.

Noted: These step using Xcode 9

like image 53
Sour LeangChhean Avatar answered Nov 16 '22 02:11

Sour LeangChhean