0

This could be a seriously dumb question, but I have checked in the terminal that my computer is using swift 1.2 right now:

$ xcrun swift -version Apple Swift version 1.2 (swiftlang-602.0.53.1 clang-602.0.53) Target: x86_64-apple-darwin14.4.0 

I want to make sure I'm using swift 2.0 in my new projects so I am learning to use things like "guard" and whatnot.

I know I can Edit -> Convert -> To lastest Swift syntax on existing code I've written, but I am wondering can you set xcode to just use swift 2.0 by default on new projects?

I find myself getting confused if my code is written incorrectly or if I am simply trying to write swift 2.0 in a swift 1.2 project. I also don't understand, is doing the edit -> convert on each file the correct way to do this?! What if I have a huge project with 100 files!?

Thanks!

2 Answers 2

4

The release version of Xcode (6.4) only supports Swift 1.2. You need to get the latest beta of Xcode 7 (beta 6). Once you have installed that (and you use it instead of the 6.x version) it will automatically use Swift 2.0.

You may also need to run xcode-select from the command line to switch the command line tools to use Swift 2.

xcode-select --switch /path/to/Xcode7/beta 

You might need to run it with sudo

Sign up to request clarification or add additional context in comments.

Comments

0

By default Xcode 7 using Swift version 2 (2.x.x) AND Xcode 6.4 using Swift 1.2. You can NOT change Xcode 7 to use SWIFT 1.x version and other way around.

If you have installed both Xcode 6.x AND 7.x versions then you have installed SWIFT 1 and 2 version in your computer.

When you check typing swift -version in terminal it provides the default configured SWIFT version (1 or 2) for command line.

If you have both can easily change it from XCODE as well.

  • XCODE -> Preferences
  • Select the XCode version in Command Line Tools Drop Box Under Location TAB

enter image description here

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.