“Use Legacy Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use Swift."
Asked Answered
A

7

17

Ever since I've updated to Xcode 8.2 (GM seed, from the App Store), I have been stuck at the following error:

Use Legacy Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use Swift. Use the [Edit > Convert > To Current Swift Syntax…] menu to choose a Swift version or use the Build Settings editor to configure the build setting directly.

So I went to my target's Build Settings, and searched for SWIFT_VERSION to see where I was erring. However, I was surprised to find that it was already set to No!

How do I fix this?

Andrew answered 15/12, 2016 at 6:36 Comment(2)
Under the hood, "Use Legacy Swift Language Version" is SWIFT_VERSION key in buildSettings. In XCode 8.1 setting the option to "No" meant SWIFT_VERSION = 3.0.1, in XCode 8.2 it's just SWIFT_VERSION = 3.0. Hence "funny" side-effects.Alegar
A key point missed in all of the responses below is that XCode 8.2 supports up to Swift3, and Swift2.x as "Legacy Swift Language Version". It was not until XCode 9 (and possibly 8.3) that Swift4 was introduced. At that time, the UI changed to show SWIFT_VERSION. So all of the answers that state just search for "SWIFT_VERSION" are wrong. It is true, you can search for this in your project.pbxproj file as the variable exists in the file even on older projects. It took me awhile to figure this out.Squeaky
A
17

Xcode 8 seems to be wrongfully displaying a nonexistent ("phantom", if you will) No. There's a trivial fix for this:

  1. Click the tiny arrow next to SWIFT_VERSION to toggle the drop-down list.
  2. Set the values for Debug and Release to Yes.
  3. Set the values for Debug and Release back to No.

The image below was taken just after setting Debug to No. Xcode shows that both Debug and Release are set to No, however SWIFT_VERSION reads <Multiple Values>:

enter image description here

From this, I can only conclude that it is a bug; and that some value (or more probably a null value) is being misrepresented as No.

Andrew answered 15/12, 2016 at 6:36 Comment(1)
I am using Xcode 9.3 and I cannot find any "Swift Compiler" or "Swift version" in the build settings... Do you have any clue ?Madea
W
16

Please select the target in pod alamofire, search 'SWIFT_VERSION', select swift3.enter image description here

Wrench answered 2/5, 2017 at 7:8 Comment(0)
T
7

Xcode 8.3.2 go to :

Build Settings > Swift Compiler - Viersion > change Swift Version

....works

Tobar answered 11/8, 2017 at 17:25 Comment(0)
M
2

Just in case anyone else runs into the same issue I just had.

I had an app that was ready to launch onto the app store but i was waiting, meanwhile i updated to Xcode 9 beta and was messing around, changed a few things in my app. I went to upload it to the app store and it said you could not use beta versions to upload so i went back to Xcode 8 but it started giving me the “Swift Language Version” (SWIFT_VERSION)..." error.

My fix

Under your project Build Settings > Swift Compiler Version > I had to change this from Swift 4(currently not supported) to Swift 3.

Problem Solved :)

Mucoid answered 24/7, 2017 at 20:56 Comment(0)
C
1

The phantom No answer will work. The real reason XCode is broken is because Apples XCode "use legacy setting" is really a Swift Version number. In XCode 8.1 'No' translated to 3.0.1, in XCode 8.2 'No' translates to 3.0. So you need to switch the version to Swift 3.0 . Which makes sense. Was a bug in XCode 8.1 I guess.

My git diff:

--- a/ios/myapp.xcodeproj/project.pbxproj
+++ b/ios/myapp.xcodeproj/project.pbxproj
@@ -1757,7 +1757,7 @@
                                SDKROOT = iphoneos;
                                SKIP_INSTALL = YES;
                                SWIFT_OPTIMIZATION_LEVEL = "-Onone";
-                               SWIFT_VERSION = 3.0.1;
+                               SWIFT_VERSION = 3.0;
                                TARGETED_DEVICE_FAMILY = "1,2";
                        };
                        name = Debug;

I see a comment above that has the same answer just think it needs to stand out more.

Canvass answered 15/12, 2016 at 22:54 Comment(0)
A
0

I've had the same problem about "Use Legacy Swift Language Version..", my have solved it by setting the version, The tips to resolve the problem are:

  1. when you open the target ,there will show a notice to "Convert to Current Swift Syntax", you should choose the "Later", next there also have a another notice ,still choose "Later".
  2. If your target already added CocoaPods, please add that code in the end of your podFile:

    post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['SWIFT_VERSION'] = '3.0' end end end

after add that code, please update cocoaPods.

  1. Click pod file,there will show all third party libraries list. find out "Build Setting" of every library,and search the "Use Legacy Swift Language Version"types, set it’s value to be YES.
  2. There may be some warnings or errors,there are come from version upload,you can correct them through the red circle prompt.

-----If you not add cocoaPods ,you can set the targets’ version be YES(TARGETS->Build Setting-->Use Legacy Swift Language Version-->YES) Hope that can help you.

Aeolotropic answered 15/12, 2016 at 7:38 Comment(0)
T
0

I had a same problem in yesterday. Fix step:

  1. Build settings -> search swift, choice use legacy swift language version

  2. Toggled no to yes -> build. You will get more error.

  3. Back toggled yes to no. build -> success!

Sometime apple make us to be come so crazy :)

All done.

Twaddle answered 16/12, 2016 at 1:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.