jlp28 jlp28 - 1 year ago 131
Swift Question

Xcode switching between Swift 2.2 and Swift 3.0

Ever since I downloaded the new Xcode and converted/updated my syntax, Xcode has been randomly switching between the above mentioned versions of Swift. I ran 'swift -version' in my Terminal and it confirmed (for the moment) that I am running Swift 2.2

I saw this question (Swift compiler is confusing version 2 and 3) but I'm too new to add a comment and ask more questions (like why can't I find that in the targets section of my project?).

How can I set my syntax so that it stays on Swift 3 and doesn't change without warning? This will be about the fourth time I've updated everything for the sake of testing/running my app.

Hopefully this is an issue for other people and this question helps them too - I feel awful asking when I'm new. I hope to be able to know enough to help other users soon.

Answer Source

You can set Swift in the Terminal to be the same version as Xcode 8's with xcode-select. Point it at Xcode beta like this:

sudo xcode-select --switch /Applications/Xcode-beta.app

You can also set the toolchain right in Xcode 8, in menu Xcode > Toolchains > Manage Toolchains:

enter image description here