How do I see which version of Swift I'm using?
up vote
429
down vote
favorite
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 am using inside my project?
swift xcode terminal
add a comment |
up vote
429
down vote
favorite
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 am using inside my project?
swift xcode terminal
5
Besides the title of stackoverflow.com/questions/29140476/… I find no similarity to this question that's enough to label this question as it's duplicate. The essence of this question is not how to find the version of Swift programmatically, but how to find the version of Swift in a general way (via terminal or Xcode or etc.). This is a big difference.
– David Snabel
Jun 6 '16 at 9:54
add a comment |
up vote
429
down vote
favorite
up vote
429
down vote
favorite
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 am using inside my project?
swift xcode terminal
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 am using inside my project?
swift xcode terminal
swift xcode terminal
edited Apr 7 at 22:32
LinusGeffarth
8,309145198
8,309145198
asked Jun 11 '15 at 19:52
David Snabel
3,43161728
3,43161728
5
Besides the title of stackoverflow.com/questions/29140476/… I find no similarity to this question that's enough to label this question as it's duplicate. The essence of this question is not how to find the version of Swift programmatically, but how to find the version of Swift in a general way (via terminal or Xcode or etc.). This is a big difference.
– David Snabel
Jun 6 '16 at 9:54
add a comment |
5
Besides the title of stackoverflow.com/questions/29140476/… I find no similarity to this question that's enough to label this question as it's duplicate. The essence of this question is not how to find the version of Swift programmatically, but how to find the version of Swift in a general way (via terminal or Xcode or etc.). This is a big difference.
– David Snabel
Jun 6 '16 at 9:54
5
5
Besides the title of stackoverflow.com/questions/29140476/… I find no similarity to this question that's enough to label this question as it's duplicate. The essence of this question is not how to find the version of Swift programmatically, but how to find the version of Swift in a general way (via terminal or Xcode or etc.). This is a big difference.
– David Snabel
Jun 6 '16 at 9:54
Besides the title of stackoverflow.com/questions/29140476/… I find no similarity to this question that's enough to label this question as it's duplicate. The essence of this question is not how to find the version of Swift programmatically, but how to find the version of Swift in a general way (via terminal or Xcode or etc.). This is a big difference.
– David Snabel
Jun 6 '16 at 9:54
add a comment |
7 Answers
7
active
oldest
votes
up vote
210
down vote
accepted
Project build settings have a block 'Swift Compiler - Languages', which stores information about Swift Language Version in key-value format. It will show you all available (supported) Swift Language Version for your Xcode and active version also by a tick mark.
Project ► (Select Your Project Target) ► Build Settings ► (Type
'swift_version' in the Search bar) Swift Compiler Language ► Swift Language
Version ► Click on Language list to open it (and there will be a tick mark on any one of list-item, that will be current swift version).
Look at this snapshot, for easy understanding:
With help of following code, programmatically you can find Swift version supported by your project.
#if swift(>=5.0)
print("Hello, Swift 5.0")
#elseif swift(>=4.2)
print("Hello, Swift 4.2")
#elseif swift(>=4.1)
print("Hello, Swift 4.1")
#elseif swift(>=4.0)
print("Hello, Swift 4.0")
#elseif swift(>=3.2)
print("Hello, Swift 3.2")
#elseif swift(>=3.0)
print("Hello, Swift 3.0")
#elseif swift(>=2.2)
print("Hello, Swift 2.2")
#elseif swift(>=2.1)
print("Hello, Swift 2.1")
#elseif swift(>=2.0)
print("Hello, Swift 2.0")
#elseif swift(>=1.2)
print("Hello, Swift 1.2")
#elseif swift(>=1.1)
print("Hello, Swift 1.1")
#elseif swift(>=1.0)
print("Hello, Swift 1.0")
#endif
Here is result using Playground (with Xcode 10.x)
9
I think this is correct answer. Easier than calling terminal. (especially if you have different version of Xcode installed)
– Mike Keskinov
Sep 12 '17 at 18:04
12
This is the correct answer because swift version is configured on a per target basis.
– Andrew Paul Simmons
Oct 3 '17 at 23:42
5
Yes you guys are right
– David Snabel
Oct 13 '17 at 10:06
2
I don't see this propoerty in my project with Xcode 8.1
– logoff
Nov 9 '17 at 9:15
5
you can see this property on latest versions of xcode
– Parkhya Dev
Nov 25 '17 at 8:01
|
show 1 more comment
up vote
453
down vote
What I do is say in the Terminal:
$ xcrun swift -version
Output for Xcode 6.3.2 is:
Apple Swift version 1.2 (swiftlang-602.0.53.1 clang-602.0.53)
Of course that assumes that your xcrun
is pointing at your copy of Xcode correctly. If, like me, you're juggling several versions of Xcode, that can be a worry! To make sure that it is, say
$ xcrun --find swift
and look at the path to Xcode that it shows you. For example:
/Applications/Xcode.app/...
If that's your Xcode, then the output from -version
is accurate. If you need to repoint xcrun
, use the Command Line Tools pop-up menu in Xcode's Locations preference pane.
No worries. It can be a real problem!
– matt
Jun 11 '15 at 20:19
7
You can also usexcode-select -p
to print the path to the Xcode that xcrun will use, andsudo xcode-select -s /path/to/Xcode.app
to change it.
– Jack Lawrence
Sep 15 '15 at 3:32
It worked fantastic.. thanks :)
– Chintan Rathod
Sep 22 '15 at 6:08
4
I just started to learn ios development and I am surprised that xcode does not let you choose the version of swift nor even let you know the version from GUI.
– Alex
Feb 8 '16 at 2:13
1
This gave me the wrong answer. Because swift is configured per target. See the answer below from @Krunal for the best answer.
– Andrew Paul Simmons
Oct 3 '17 at 23:42
|
show 5 more comments
up vote
86
down vote
Open the Terminal and write:
swift -version
9
This is not necessarily the version of swift that Xcode sees. Besides, you can have swift without having Xcode.
– asiby
Apr 18 '17 at 22:12
1
Well at least it is working~
– kit
Nov 24 at 7:25
add a comment |
up vote
60
down vote
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
(ReplaceXcode_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.
Thank you sir. I got many things from your answer
– Kyle KIM
Jul 24 '17 at 1:01
add a comment |
up vote
18
down vote
This reddit post helped me:
https://www.reddit.com/r/swift/comments/4o8atc/xcode_8_which_swift/d4anpet
Xcode 8 uses Swift 3.0 as default. But you can turn on Swift 2.3. Go to project's Build Settings and set 'Use Legacy Swift Language Version' to YES.
Good old reddit :)
1
I can't find this by search 'Use Legacy Swift Language Version' or 'Legacy'
– JerryZhou
Jun 8 '17 at 7:37
I'm using latest Xcode Version 8.3.2 (8E2002) and swift 3 there in Swift Language Version. Now I want to change this to swift 2.3 but there is only one option swift 3.0 and 2nd is unspecified. so would you please guide how this would be possible ? to get swift 2.3 in my current project? @alexisSchreier
– Arsal
Jun 19 '17 at 19:47
1
@Arsal download Xcode 8.2.... You can no longer use Swift 2.3 once in Xcode 8.3
– William GP
Jul 13 '17 at 23:35
add a comment |
up vote
18
down vote
You can see and select which Swift version Xcode is using in:
Target -> Build Settings -> Swift Language Version:
This is available in Xcode 8.3 and Xcode 9 (haven't checked older versions)
2
Bleeding edge answer with Swift 4.0 :)
– Chris Prince
Jun 14 '17 at 14:57
2
Swift Language Version
doesn't come up as a setting in my Xcode 8.2.1 project. It does haveUse Legacy Swift Language Version
.
– Chris Prince
Jun 14 '17 at 15:00
1
@ChrisPrince Yes,Swift Language Version
didn't exist here inBuild Settings
until Xcode 8.3.... in prior Xcode 8.x versionsUse Legacy Swift Language Version
,No
= Swift 3, andYes
= Swift 2.3
– William GP
Jul 13 '17 at 23:32
This answer is easier to comprehend than the others. 👍
– eonist
Aug 15 '17 at 19:22
add a comment |
up vote
2
down vote
To see the default version of swift installed on your machine then from the command line, type the following :
swift --version
Apple Swift version 4.1.2 (swiftlang-902.0.54 clang-902.0.39.2)
Target: x86_64-apple-darwin17.6.0
This is most likely the version that is included in the app store version of Xcode that you have installed (unless you have changed it).
If you want to determine the actual version of Swift being used by a particular version of Xcode (a beta, for instance) then from the command line, invoke the swift binary within the Xcode bundle and pass it the parameter --version
/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift --version
Apple Swift version 4.2 (swiftlang-1000.0.16.7 clang-1000.10.25.3)
Target: x86_64-apple-darwin17.6.0
add a comment |
7 Answers
7
active
oldest
votes
7 Answers
7
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
210
down vote
accepted
Project build settings have a block 'Swift Compiler - Languages', which stores information about Swift Language Version in key-value format. It will show you all available (supported) Swift Language Version for your Xcode and active version also by a tick mark.
Project ► (Select Your Project Target) ► Build Settings ► (Type
'swift_version' in the Search bar) Swift Compiler Language ► Swift Language
Version ► Click on Language list to open it (and there will be a tick mark on any one of list-item, that will be current swift version).
Look at this snapshot, for easy understanding:
With help of following code, programmatically you can find Swift version supported by your project.
#if swift(>=5.0)
print("Hello, Swift 5.0")
#elseif swift(>=4.2)
print("Hello, Swift 4.2")
#elseif swift(>=4.1)
print("Hello, Swift 4.1")
#elseif swift(>=4.0)
print("Hello, Swift 4.0")
#elseif swift(>=3.2)
print("Hello, Swift 3.2")
#elseif swift(>=3.0)
print("Hello, Swift 3.0")
#elseif swift(>=2.2)
print("Hello, Swift 2.2")
#elseif swift(>=2.1)
print("Hello, Swift 2.1")
#elseif swift(>=2.0)
print("Hello, Swift 2.0")
#elseif swift(>=1.2)
print("Hello, Swift 1.2")
#elseif swift(>=1.1)
print("Hello, Swift 1.1")
#elseif swift(>=1.0)
print("Hello, Swift 1.0")
#endif
Here is result using Playground (with Xcode 10.x)
9
I think this is correct answer. Easier than calling terminal. (especially if you have different version of Xcode installed)
– Mike Keskinov
Sep 12 '17 at 18:04
12
This is the correct answer because swift version is configured on a per target basis.
– Andrew Paul Simmons
Oct 3 '17 at 23:42
5
Yes you guys are right
– David Snabel
Oct 13 '17 at 10:06
2
I don't see this propoerty in my project with Xcode 8.1
– logoff
Nov 9 '17 at 9:15
5
you can see this property on latest versions of xcode
– Parkhya Dev
Nov 25 '17 at 8:01
|
show 1 more comment
up vote
210
down vote
accepted
Project build settings have a block 'Swift Compiler - Languages', which stores information about Swift Language Version in key-value format. It will show you all available (supported) Swift Language Version for your Xcode and active version also by a tick mark.
Project ► (Select Your Project Target) ► Build Settings ► (Type
'swift_version' in the Search bar) Swift Compiler Language ► Swift Language
Version ► Click on Language list to open it (and there will be a tick mark on any one of list-item, that will be current swift version).
Look at this snapshot, for easy understanding:
With help of following code, programmatically you can find Swift version supported by your project.
#if swift(>=5.0)
print("Hello, Swift 5.0")
#elseif swift(>=4.2)
print("Hello, Swift 4.2")
#elseif swift(>=4.1)
print("Hello, Swift 4.1")
#elseif swift(>=4.0)
print("Hello, Swift 4.0")
#elseif swift(>=3.2)
print("Hello, Swift 3.2")
#elseif swift(>=3.0)
print("Hello, Swift 3.0")
#elseif swift(>=2.2)
print("Hello, Swift 2.2")
#elseif swift(>=2.1)
print("Hello, Swift 2.1")
#elseif swift(>=2.0)
print("Hello, Swift 2.0")
#elseif swift(>=1.2)
print("Hello, Swift 1.2")
#elseif swift(>=1.1)
print("Hello, Swift 1.1")
#elseif swift(>=1.0)
print("Hello, Swift 1.0")
#endif
Here is result using Playground (with Xcode 10.x)
9
I think this is correct answer. Easier than calling terminal. (especially if you have different version of Xcode installed)
– Mike Keskinov
Sep 12 '17 at 18:04
12
This is the correct answer because swift version is configured on a per target basis.
– Andrew Paul Simmons
Oct 3 '17 at 23:42
5
Yes you guys are right
– David Snabel
Oct 13 '17 at 10:06
2
I don't see this propoerty in my project with Xcode 8.1
– logoff
Nov 9 '17 at 9:15
5
you can see this property on latest versions of xcode
– Parkhya Dev
Nov 25 '17 at 8:01
|
show 1 more comment
up vote
210
down vote
accepted
up vote
210
down vote
accepted
Project build settings have a block 'Swift Compiler - Languages', which stores information about Swift Language Version in key-value format. It will show you all available (supported) Swift Language Version for your Xcode and active version also by a tick mark.
Project ► (Select Your Project Target) ► Build Settings ► (Type
'swift_version' in the Search bar) Swift Compiler Language ► Swift Language
Version ► Click on Language list to open it (and there will be a tick mark on any one of list-item, that will be current swift version).
Look at this snapshot, for easy understanding:
With help of following code, programmatically you can find Swift version supported by your project.
#if swift(>=5.0)
print("Hello, Swift 5.0")
#elseif swift(>=4.2)
print("Hello, Swift 4.2")
#elseif swift(>=4.1)
print("Hello, Swift 4.1")
#elseif swift(>=4.0)
print("Hello, Swift 4.0")
#elseif swift(>=3.2)
print("Hello, Swift 3.2")
#elseif swift(>=3.0)
print("Hello, Swift 3.0")
#elseif swift(>=2.2)
print("Hello, Swift 2.2")
#elseif swift(>=2.1)
print("Hello, Swift 2.1")
#elseif swift(>=2.0)
print("Hello, Swift 2.0")
#elseif swift(>=1.2)
print("Hello, Swift 1.2")
#elseif swift(>=1.1)
print("Hello, Swift 1.1")
#elseif swift(>=1.0)
print("Hello, Swift 1.0")
#endif
Here is result using Playground (with Xcode 10.x)
Project build settings have a block 'Swift Compiler - Languages', which stores information about Swift Language Version in key-value format. It will show you all available (supported) Swift Language Version for your Xcode and active version also by a tick mark.
Project ► (Select Your Project Target) ► Build Settings ► (Type
'swift_version' in the Search bar) Swift Compiler Language ► Swift Language
Version ► Click on Language list to open it (and there will be a tick mark on any one of list-item, that will be current swift version).
Look at this snapshot, for easy understanding:
With help of following code, programmatically you can find Swift version supported by your project.
#if swift(>=5.0)
print("Hello, Swift 5.0")
#elseif swift(>=4.2)
print("Hello, Swift 4.2")
#elseif swift(>=4.1)
print("Hello, Swift 4.1")
#elseif swift(>=4.0)
print("Hello, Swift 4.0")
#elseif swift(>=3.2)
print("Hello, Swift 3.2")
#elseif swift(>=3.0)
print("Hello, Swift 3.0")
#elseif swift(>=2.2)
print("Hello, Swift 2.2")
#elseif swift(>=2.1)
print("Hello, Swift 2.1")
#elseif swift(>=2.0)
print("Hello, Swift 2.0")
#elseif swift(>=1.2)
print("Hello, Swift 1.2")
#elseif swift(>=1.1)
print("Hello, Swift 1.1")
#elseif swift(>=1.0)
print("Hello, Swift 1.0")
#endif
Here is result using Playground (with Xcode 10.x)
edited Nov 10 at 3:49
answered Sep 6 '17 at 17:10
Krunal
36.3k20131160
36.3k20131160
9
I think this is correct answer. Easier than calling terminal. (especially if you have different version of Xcode installed)
– Mike Keskinov
Sep 12 '17 at 18:04
12
This is the correct answer because swift version is configured on a per target basis.
– Andrew Paul Simmons
Oct 3 '17 at 23:42
5
Yes you guys are right
– David Snabel
Oct 13 '17 at 10:06
2
I don't see this propoerty in my project with Xcode 8.1
– logoff
Nov 9 '17 at 9:15
5
you can see this property on latest versions of xcode
– Parkhya Dev
Nov 25 '17 at 8:01
|
show 1 more comment
9
I think this is correct answer. Easier than calling terminal. (especially if you have different version of Xcode installed)
– Mike Keskinov
Sep 12 '17 at 18:04
12
This is the correct answer because swift version is configured on a per target basis.
– Andrew Paul Simmons
Oct 3 '17 at 23:42
5
Yes you guys are right
– David Snabel
Oct 13 '17 at 10:06
2
I don't see this propoerty in my project with Xcode 8.1
– logoff
Nov 9 '17 at 9:15
5
you can see this property on latest versions of xcode
– Parkhya Dev
Nov 25 '17 at 8:01
9
9
I think this is correct answer. Easier than calling terminal. (especially if you have different version of Xcode installed)
– Mike Keskinov
Sep 12 '17 at 18:04
I think this is correct answer. Easier than calling terminal. (especially if you have different version of Xcode installed)
– Mike Keskinov
Sep 12 '17 at 18:04
12
12
This is the correct answer because swift version is configured on a per target basis.
– Andrew Paul Simmons
Oct 3 '17 at 23:42
This is the correct answer because swift version is configured on a per target basis.
– Andrew Paul Simmons
Oct 3 '17 at 23:42
5
5
Yes you guys are right
– David Snabel
Oct 13 '17 at 10:06
Yes you guys are right
– David Snabel
Oct 13 '17 at 10:06
2
2
I don't see this propoerty in my project with Xcode 8.1
– logoff
Nov 9 '17 at 9:15
I don't see this propoerty in my project with Xcode 8.1
– logoff
Nov 9 '17 at 9:15
5
5
you can see this property on latest versions of xcode
– Parkhya Dev
Nov 25 '17 at 8:01
you can see this property on latest versions of xcode
– Parkhya Dev
Nov 25 '17 at 8:01
|
show 1 more comment
up vote
453
down vote
What I do is say in the Terminal:
$ xcrun swift -version
Output for Xcode 6.3.2 is:
Apple Swift version 1.2 (swiftlang-602.0.53.1 clang-602.0.53)
Of course that assumes that your xcrun
is pointing at your copy of Xcode correctly. If, like me, you're juggling several versions of Xcode, that can be a worry! To make sure that it is, say
$ xcrun --find swift
and look at the path to Xcode that it shows you. For example:
/Applications/Xcode.app/...
If that's your Xcode, then the output from -version
is accurate. If you need to repoint xcrun
, use the Command Line Tools pop-up menu in Xcode's Locations preference pane.
No worries. It can be a real problem!
– matt
Jun 11 '15 at 20:19
7
You can also usexcode-select -p
to print the path to the Xcode that xcrun will use, andsudo xcode-select -s /path/to/Xcode.app
to change it.
– Jack Lawrence
Sep 15 '15 at 3:32
It worked fantastic.. thanks :)
– Chintan Rathod
Sep 22 '15 at 6:08
4
I just started to learn ios development and I am surprised that xcode does not let you choose the version of swift nor even let you know the version from GUI.
– Alex
Feb 8 '16 at 2:13
1
This gave me the wrong answer. Because swift is configured per target. See the answer below from @Krunal for the best answer.
– Andrew Paul Simmons
Oct 3 '17 at 23:42
|
show 5 more comments
up vote
453
down vote
What I do is say in the Terminal:
$ xcrun swift -version
Output for Xcode 6.3.2 is:
Apple Swift version 1.2 (swiftlang-602.0.53.1 clang-602.0.53)
Of course that assumes that your xcrun
is pointing at your copy of Xcode correctly. If, like me, you're juggling several versions of Xcode, that can be a worry! To make sure that it is, say
$ xcrun --find swift
and look at the path to Xcode that it shows you. For example:
/Applications/Xcode.app/...
If that's your Xcode, then the output from -version
is accurate. If you need to repoint xcrun
, use the Command Line Tools pop-up menu in Xcode's Locations preference pane.
No worries. It can be a real problem!
– matt
Jun 11 '15 at 20:19
7
You can also usexcode-select -p
to print the path to the Xcode that xcrun will use, andsudo xcode-select -s /path/to/Xcode.app
to change it.
– Jack Lawrence
Sep 15 '15 at 3:32
It worked fantastic.. thanks :)
– Chintan Rathod
Sep 22 '15 at 6:08
4
I just started to learn ios development and I am surprised that xcode does not let you choose the version of swift nor even let you know the version from GUI.
– Alex
Feb 8 '16 at 2:13
1
This gave me the wrong answer. Because swift is configured per target. See the answer below from @Krunal for the best answer.
– Andrew Paul Simmons
Oct 3 '17 at 23:42
|
show 5 more comments
up vote
453
down vote
up vote
453
down vote
What I do is say in the Terminal:
$ xcrun swift -version
Output for Xcode 6.3.2 is:
Apple Swift version 1.2 (swiftlang-602.0.53.1 clang-602.0.53)
Of course that assumes that your xcrun
is pointing at your copy of Xcode correctly. If, like me, you're juggling several versions of Xcode, that can be a worry! To make sure that it is, say
$ xcrun --find swift
and look at the path to Xcode that it shows you. For example:
/Applications/Xcode.app/...
If that's your Xcode, then the output from -version
is accurate. If you need to repoint xcrun
, use the Command Line Tools pop-up menu in Xcode's Locations preference pane.
What I do is say in the Terminal:
$ xcrun swift -version
Output for Xcode 6.3.2 is:
Apple Swift version 1.2 (swiftlang-602.0.53.1 clang-602.0.53)
Of course that assumes that your xcrun
is pointing at your copy of Xcode correctly. If, like me, you're juggling several versions of Xcode, that can be a worry! To make sure that it is, say
$ xcrun --find swift
and look at the path to Xcode that it shows you. For example:
/Applications/Xcode.app/...
If that's your Xcode, then the output from -version
is accurate. If you need to repoint xcrun
, use the Command Line Tools pop-up menu in Xcode's Locations preference pane.
edited Jun 11 '15 at 20:18
answered Jun 11 '15 at 20:13
matt
318k44515716
318k44515716
No worries. It can be a real problem!
– matt
Jun 11 '15 at 20:19
7
You can also usexcode-select -p
to print the path to the Xcode that xcrun will use, andsudo xcode-select -s /path/to/Xcode.app
to change it.
– Jack Lawrence
Sep 15 '15 at 3:32
It worked fantastic.. thanks :)
– Chintan Rathod
Sep 22 '15 at 6:08
4
I just started to learn ios development and I am surprised that xcode does not let you choose the version of swift nor even let you know the version from GUI.
– Alex
Feb 8 '16 at 2:13
1
This gave me the wrong answer. Because swift is configured per target. See the answer below from @Krunal for the best answer.
– Andrew Paul Simmons
Oct 3 '17 at 23:42
|
show 5 more comments
No worries. It can be a real problem!
– matt
Jun 11 '15 at 20:19
7
You can also usexcode-select -p
to print the path to the Xcode that xcrun will use, andsudo xcode-select -s /path/to/Xcode.app
to change it.
– Jack Lawrence
Sep 15 '15 at 3:32
It worked fantastic.. thanks :)
– Chintan Rathod
Sep 22 '15 at 6:08
4
I just started to learn ios development and I am surprised that xcode does not let you choose the version of swift nor even let you know the version from GUI.
– Alex
Feb 8 '16 at 2:13
1
This gave me the wrong answer. Because swift is configured per target. See the answer below from @Krunal for the best answer.
– Andrew Paul Simmons
Oct 3 '17 at 23:42
No worries. It can be a real problem!
– matt
Jun 11 '15 at 20:19
No worries. It can be a real problem!
– matt
Jun 11 '15 at 20:19
7
7
You can also use
xcode-select -p
to print the path to the Xcode that xcrun will use, and sudo xcode-select -s /path/to/Xcode.app
to change it.– Jack Lawrence
Sep 15 '15 at 3:32
You can also use
xcode-select -p
to print the path to the Xcode that xcrun will use, and sudo xcode-select -s /path/to/Xcode.app
to change it.– Jack Lawrence
Sep 15 '15 at 3:32
It worked fantastic.. thanks :)
– Chintan Rathod
Sep 22 '15 at 6:08
It worked fantastic.. thanks :)
– Chintan Rathod
Sep 22 '15 at 6:08
4
4
I just started to learn ios development and I am surprised that xcode does not let you choose the version of swift nor even let you know the version from GUI.
– Alex
Feb 8 '16 at 2:13
I just started to learn ios development and I am surprised that xcode does not let you choose the version of swift nor even let you know the version from GUI.
– Alex
Feb 8 '16 at 2:13
1
1
This gave me the wrong answer. Because swift is configured per target. See the answer below from @Krunal for the best answer.
– Andrew Paul Simmons
Oct 3 '17 at 23:42
This gave me the wrong answer. Because swift is configured per target. See the answer below from @Krunal for the best answer.
– Andrew Paul Simmons
Oct 3 '17 at 23:42
|
show 5 more comments
up vote
86
down vote
Open the Terminal and write:
swift -version
9
This is not necessarily the version of swift that Xcode sees. Besides, you can have swift without having Xcode.
– asiby
Apr 18 '17 at 22:12
1
Well at least it is working~
– kit
Nov 24 at 7:25
add a comment |
up vote
86
down vote
Open the Terminal and write:
swift -version
9
This is not necessarily the version of swift that Xcode sees. Besides, you can have swift without having Xcode.
– asiby
Apr 18 '17 at 22:12
1
Well at least it is working~
– kit
Nov 24 at 7:25
add a comment |
up vote
86
down vote
up vote
86
down vote
Open the Terminal and write:
swift -version
Open the Terminal and write:
swift -version
edited Jan 24 '17 at 11:27
answered Jun 2 '16 at 18:44
Alzayed
1,007810
1,007810
9
This is not necessarily the version of swift that Xcode sees. Besides, you can have swift without having Xcode.
– asiby
Apr 18 '17 at 22:12
1
Well at least it is working~
– kit
Nov 24 at 7:25
add a comment |
9
This is not necessarily the version of swift that Xcode sees. Besides, you can have swift without having Xcode.
– asiby
Apr 18 '17 at 22:12
1
Well at least it is working~
– kit
Nov 24 at 7:25
9
9
This is not necessarily the version of swift that Xcode sees. Besides, you can have swift without having Xcode.
– asiby
Apr 18 '17 at 22:12
This is not necessarily the version of swift that Xcode sees. Besides, you can have swift without having Xcode.
– asiby
Apr 18 '17 at 22:12
1
1
Well at least it is working~
– kit
Nov 24 at 7:25
Well at least it is working~
– kit
Nov 24 at 7:25
add a comment |
up vote
60
down vote
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
(ReplaceXcode_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.
Thank you sir. I got many things from your answer
– Kyle KIM
Jul 24 '17 at 1:01
add a comment |
up vote
60
down vote
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
(ReplaceXcode_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.
Thank you sir. I got many things from your answer
– Kyle KIM
Jul 24 '17 at 1:01
add a comment |
up vote
60
down vote
up vote
60
down vote
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
(ReplaceXcode_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.
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
(ReplaceXcode_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.
edited Aug 3 '17 at 9:34
answered Jul 18 '16 at 20:49
Aditya Deshmane
3,51622329
3,51622329
Thank you sir. I got many things from your answer
– Kyle KIM
Jul 24 '17 at 1:01
add a comment |
Thank you sir. I got many things from your answer
– Kyle KIM
Jul 24 '17 at 1:01
Thank you sir. I got many things from your answer
– Kyle KIM
Jul 24 '17 at 1:01
Thank you sir. I got many things from your answer
– Kyle KIM
Jul 24 '17 at 1:01
add a comment |
up vote
18
down vote
This reddit post helped me:
https://www.reddit.com/r/swift/comments/4o8atc/xcode_8_which_swift/d4anpet
Xcode 8 uses Swift 3.0 as default. But you can turn on Swift 2.3. Go to project's Build Settings and set 'Use Legacy Swift Language Version' to YES.
Good old reddit :)
1
I can't find this by search 'Use Legacy Swift Language Version' or 'Legacy'
– JerryZhou
Jun 8 '17 at 7:37
I'm using latest Xcode Version 8.3.2 (8E2002) and swift 3 there in Swift Language Version. Now I want to change this to swift 2.3 but there is only one option swift 3.0 and 2nd is unspecified. so would you please guide how this would be possible ? to get swift 2.3 in my current project? @alexisSchreier
– Arsal
Jun 19 '17 at 19:47
1
@Arsal download Xcode 8.2.... You can no longer use Swift 2.3 once in Xcode 8.3
– William GP
Jul 13 '17 at 23:35
add a comment |
up vote
18
down vote
This reddit post helped me:
https://www.reddit.com/r/swift/comments/4o8atc/xcode_8_which_swift/d4anpet
Xcode 8 uses Swift 3.0 as default. But you can turn on Swift 2.3. Go to project's Build Settings and set 'Use Legacy Swift Language Version' to YES.
Good old reddit :)
1
I can't find this by search 'Use Legacy Swift Language Version' or 'Legacy'
– JerryZhou
Jun 8 '17 at 7:37
I'm using latest Xcode Version 8.3.2 (8E2002) and swift 3 there in Swift Language Version. Now I want to change this to swift 2.3 but there is only one option swift 3.0 and 2nd is unspecified. so would you please guide how this would be possible ? to get swift 2.3 in my current project? @alexisSchreier
– Arsal
Jun 19 '17 at 19:47
1
@Arsal download Xcode 8.2.... You can no longer use Swift 2.3 once in Xcode 8.3
– William GP
Jul 13 '17 at 23:35
add a comment |
up vote
18
down vote
up vote
18
down vote
This reddit post helped me:
https://www.reddit.com/r/swift/comments/4o8atc/xcode_8_which_swift/d4anpet
Xcode 8 uses Swift 3.0 as default. But you can turn on Swift 2.3. Go to project's Build Settings and set 'Use Legacy Swift Language Version' to YES.
Good old reddit :)
This reddit post helped me:
https://www.reddit.com/r/swift/comments/4o8atc/xcode_8_which_swift/d4anpet
Xcode 8 uses Swift 3.0 as default. But you can turn on Swift 2.3. Go to project's Build Settings and set 'Use Legacy Swift Language Version' to YES.
Good old reddit :)
answered Oct 14 '16 at 2:38
alexisSchreier
422413
422413
1
I can't find this by search 'Use Legacy Swift Language Version' or 'Legacy'
– JerryZhou
Jun 8 '17 at 7:37
I'm using latest Xcode Version 8.3.2 (8E2002) and swift 3 there in Swift Language Version. Now I want to change this to swift 2.3 but there is only one option swift 3.0 and 2nd is unspecified. so would you please guide how this would be possible ? to get swift 2.3 in my current project? @alexisSchreier
– Arsal
Jun 19 '17 at 19:47
1
@Arsal download Xcode 8.2.... You can no longer use Swift 2.3 once in Xcode 8.3
– William GP
Jul 13 '17 at 23:35
add a comment |
1
I can't find this by search 'Use Legacy Swift Language Version' or 'Legacy'
– JerryZhou
Jun 8 '17 at 7:37
I'm using latest Xcode Version 8.3.2 (8E2002) and swift 3 there in Swift Language Version. Now I want to change this to swift 2.3 but there is only one option swift 3.0 and 2nd is unspecified. so would you please guide how this would be possible ? to get swift 2.3 in my current project? @alexisSchreier
– Arsal
Jun 19 '17 at 19:47
1
@Arsal download Xcode 8.2.... You can no longer use Swift 2.3 once in Xcode 8.3
– William GP
Jul 13 '17 at 23:35
1
1
I can't find this by search 'Use Legacy Swift Language Version' or 'Legacy'
– JerryZhou
Jun 8 '17 at 7:37
I can't find this by search 'Use Legacy Swift Language Version' or 'Legacy'
– JerryZhou
Jun 8 '17 at 7:37
I'm using latest Xcode Version 8.3.2 (8E2002) and swift 3 there in Swift Language Version. Now I want to change this to swift 2.3 but there is only one option swift 3.0 and 2nd is unspecified. so would you please guide how this would be possible ? to get swift 2.3 in my current project? @alexisSchreier
– Arsal
Jun 19 '17 at 19:47
I'm using latest Xcode Version 8.3.2 (8E2002) and swift 3 there in Swift Language Version. Now I want to change this to swift 2.3 but there is only one option swift 3.0 and 2nd is unspecified. so would you please guide how this would be possible ? to get swift 2.3 in my current project? @alexisSchreier
– Arsal
Jun 19 '17 at 19:47
1
1
@Arsal download Xcode 8.2.... You can no longer use Swift 2.3 once in Xcode 8.3
– William GP
Jul 13 '17 at 23:35
@Arsal download Xcode 8.2.... You can no longer use Swift 2.3 once in Xcode 8.3
– William GP
Jul 13 '17 at 23:35
add a comment |
up vote
18
down vote
You can see and select which Swift version Xcode is using in:
Target -> Build Settings -> Swift Language Version:
This is available in Xcode 8.3 and Xcode 9 (haven't checked older versions)
2
Bleeding edge answer with Swift 4.0 :)
– Chris Prince
Jun 14 '17 at 14:57
2
Swift Language Version
doesn't come up as a setting in my Xcode 8.2.1 project. It does haveUse Legacy Swift Language Version
.
– Chris Prince
Jun 14 '17 at 15:00
1
@ChrisPrince Yes,Swift Language Version
didn't exist here inBuild Settings
until Xcode 8.3.... in prior Xcode 8.x versionsUse Legacy Swift Language Version
,No
= Swift 3, andYes
= Swift 2.3
– William GP
Jul 13 '17 at 23:32
This answer is easier to comprehend than the others. 👍
– eonist
Aug 15 '17 at 19:22
add a comment |
up vote
18
down vote
You can see and select which Swift version Xcode is using in:
Target -> Build Settings -> Swift Language Version:
This is available in Xcode 8.3 and Xcode 9 (haven't checked older versions)
2
Bleeding edge answer with Swift 4.0 :)
– Chris Prince
Jun 14 '17 at 14:57
2
Swift Language Version
doesn't come up as a setting in my Xcode 8.2.1 project. It does haveUse Legacy Swift Language Version
.
– Chris Prince
Jun 14 '17 at 15:00
1
@ChrisPrince Yes,Swift Language Version
didn't exist here inBuild Settings
until Xcode 8.3.... in prior Xcode 8.x versionsUse Legacy Swift Language Version
,No
= Swift 3, andYes
= Swift 2.3
– William GP
Jul 13 '17 at 23:32
This answer is easier to comprehend than the others. 👍
– eonist
Aug 15 '17 at 19:22
add a comment |
up vote
18
down vote
up vote
18
down vote
You can see and select which Swift version Xcode is using in:
Target -> Build Settings -> Swift Language Version:
This is available in Xcode 8.3 and Xcode 9 (haven't checked older versions)
You can see and select which Swift version Xcode is using in:
Target -> Build Settings -> Swift Language Version:
This is available in Xcode 8.3 and Xcode 9 (haven't checked older versions)
answered Jun 9 '17 at 15:38
joern
20.3k66380
20.3k66380
2
Bleeding edge answer with Swift 4.0 :)
– Chris Prince
Jun 14 '17 at 14:57
2
Swift Language Version
doesn't come up as a setting in my Xcode 8.2.1 project. It does haveUse Legacy Swift Language Version
.
– Chris Prince
Jun 14 '17 at 15:00
1
@ChrisPrince Yes,Swift Language Version
didn't exist here inBuild Settings
until Xcode 8.3.... in prior Xcode 8.x versionsUse Legacy Swift Language Version
,No
= Swift 3, andYes
= Swift 2.3
– William GP
Jul 13 '17 at 23:32
This answer is easier to comprehend than the others. 👍
– eonist
Aug 15 '17 at 19:22
add a comment |
2
Bleeding edge answer with Swift 4.0 :)
– Chris Prince
Jun 14 '17 at 14:57
2
Swift Language Version
doesn't come up as a setting in my Xcode 8.2.1 project. It does haveUse Legacy Swift Language Version
.
– Chris Prince
Jun 14 '17 at 15:00
1
@ChrisPrince Yes,Swift Language Version
didn't exist here inBuild Settings
until Xcode 8.3.... in prior Xcode 8.x versionsUse Legacy Swift Language Version
,No
= Swift 3, andYes
= Swift 2.3
– William GP
Jul 13 '17 at 23:32
This answer is easier to comprehend than the others. 👍
– eonist
Aug 15 '17 at 19:22
2
2
Bleeding edge answer with Swift 4.0 :)
– Chris Prince
Jun 14 '17 at 14:57
Bleeding edge answer with Swift 4.0 :)
– Chris Prince
Jun 14 '17 at 14:57
2
2
Swift Language Version
doesn't come up as a setting in my Xcode 8.2.1 project. It does have Use Legacy Swift Language Version
.– Chris Prince
Jun 14 '17 at 15:00
Swift Language Version
doesn't come up as a setting in my Xcode 8.2.1 project. It does have Use Legacy Swift Language Version
.– Chris Prince
Jun 14 '17 at 15:00
1
1
@ChrisPrince Yes,
Swift Language Version
didn't exist here in Build Settings
until Xcode 8.3.... in prior Xcode 8.x versions Use Legacy Swift Language Version
, No
= Swift 3, and Yes
= Swift 2.3– William GP
Jul 13 '17 at 23:32
@ChrisPrince Yes,
Swift Language Version
didn't exist here in Build Settings
until Xcode 8.3.... in prior Xcode 8.x versions Use Legacy Swift Language Version
, No
= Swift 3, and Yes
= Swift 2.3– William GP
Jul 13 '17 at 23:32
This answer is easier to comprehend than the others. 👍
– eonist
Aug 15 '17 at 19:22
This answer is easier to comprehend than the others. 👍
– eonist
Aug 15 '17 at 19:22
add a comment |
up vote
2
down vote
To see the default version of swift installed on your machine then from the command line, type the following :
swift --version
Apple Swift version 4.1.2 (swiftlang-902.0.54 clang-902.0.39.2)
Target: x86_64-apple-darwin17.6.0
This is most likely the version that is included in the app store version of Xcode that you have installed (unless you have changed it).
If you want to determine the actual version of Swift being used by a particular version of Xcode (a beta, for instance) then from the command line, invoke the swift binary within the Xcode bundle and pass it the parameter --version
/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift --version
Apple Swift version 4.2 (swiftlang-1000.0.16.7 clang-1000.10.25.3)
Target: x86_64-apple-darwin17.6.0
add a comment |
up vote
2
down vote
To see the default version of swift installed on your machine then from the command line, type the following :
swift --version
Apple Swift version 4.1.2 (swiftlang-902.0.54 clang-902.0.39.2)
Target: x86_64-apple-darwin17.6.0
This is most likely the version that is included in the app store version of Xcode that you have installed (unless you have changed it).
If you want to determine the actual version of Swift being used by a particular version of Xcode (a beta, for instance) then from the command line, invoke the swift binary within the Xcode bundle and pass it the parameter --version
/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift --version
Apple Swift version 4.2 (swiftlang-1000.0.16.7 clang-1000.10.25.3)
Target: x86_64-apple-darwin17.6.0
add a comment |
up vote
2
down vote
up vote
2
down vote
To see the default version of swift installed on your machine then from the command line, type the following :
swift --version
Apple Swift version 4.1.2 (swiftlang-902.0.54 clang-902.0.39.2)
Target: x86_64-apple-darwin17.6.0
This is most likely the version that is included in the app store version of Xcode that you have installed (unless you have changed it).
If you want to determine the actual version of Swift being used by a particular version of Xcode (a beta, for instance) then from the command line, invoke the swift binary within the Xcode bundle and pass it the parameter --version
/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift --version
Apple Swift version 4.2 (swiftlang-1000.0.16.7 clang-1000.10.25.3)
Target: x86_64-apple-darwin17.6.0
To see the default version of swift installed on your machine then from the command line, type the following :
swift --version
Apple Swift version 4.1.2 (swiftlang-902.0.54 clang-902.0.39.2)
Target: x86_64-apple-darwin17.6.0
This is most likely the version that is included in the app store version of Xcode that you have installed (unless you have changed it).
If you want to determine the actual version of Swift being used by a particular version of Xcode (a beta, for instance) then from the command line, invoke the swift binary within the Xcode bundle and pass it the parameter --version
/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift --version
Apple Swift version 4.2 (swiftlang-1000.0.16.7 clang-1000.10.25.3)
Target: x86_64-apple-darwin17.6.0
answered Jun 12 at 15:47
paul king
694513
694513
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f30790188%2fhow-do-i-see-which-version-of-swift-im-using%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
5
Besides the title of stackoverflow.com/questions/29140476/… I find no similarity to this question that's enough to label this question as it's duplicate. The essence of this question is not how to find the version of Swift programmatically, but how to find the version of Swift in a general way (via terminal or Xcode or etc.). This is a big difference.
– David Snabel
Jun 6 '16 at 9:54