20

After updating to Xcode 8.2 the compiler throws one error for my App target:

“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.

But have it set to No in all targets I have. Tried to remove Derived Data, clean project dir, restart Xcode. Nothing helps. Anyone figure it out?

// Edited

Just to be sure: I have set to ALL my targets Use Legacy Swift Language Version to No and the project worked alright when compiled in Xcode 8.1. It doesn't work after updating to Xcode 8.2.

// Edit 21.12.

The issue has been fixed in Xcode 8.2.1

Cœur
  • 37,241
  • 25
  • 195
  • 267
Aleš Oskar Kocur
  • 1,381
  • 1
  • 13
  • 29

9 Answers9

33

Found work around. I went through each target (and project settings, so both in the project and target) in my project, toggled the "Use Legacy Swift Language Version" from "No" to "Yes" and back to "No" for each. The project then built again.

enter image description here

zumzum
  • 17,984
  • 26
  • 111
  • 172
  • 1
    OK, this solution actually did work for me. However, I could no longer see this setting in Xcode because I had previously chosen `Show Setting Names` and `Show Definitions` from the `Editor` menu. For further information, `Legacy Version = No` corresponds to `SWIFT_VERSION = 3.0`, `Yes` corresponds to `SWIFT_VERSION = 2.3`, and `Unspecified` corresponds to `SWIFT_VERSION = ''` – dave Dec 13 '16 at 16:26
  • 1
    How can you find out this creepy solution XDDD, but it does work!! – PatrickSCLin Dec 14 '16 at 11:06
  • 1
    @PatrickSCLin I've seen these kind of bugs in Xcode for many years, unfortunately... also, I checked on the solution before posting by looking at the actual raw settings file of the Xcode project.... – zumzum Dec 15 '16 at 17:02
  • Worked for! Had problems after Cocoapods install – Kimdv Dec 15 '16 at 17:40
  • The funny thing is that this bug was already in the beta but Apple didn't fix it :D – Luca D'Alberti Dec 16 '16 at 07:30
  • This solution triggers a change in the `project.pbxproj` from `SWIFT_VERSION = 3.0.1` to `SWIFT_VERSION = 3.0`. This can also be done manually, if you have a lot of targets/subprojects. See my answer below. – Klaas Dec 16 '16 at 23:54
  • 9
    Use Legacy Swift Language Version this no longer exists in Xcode 8.3.2 – coder Jun 03 '17 at 06:29
  • Update: Xcode9 does not support this anymore, manually you should change or else downgrade the Xcode version. – GvSharma Sep 22 '17 at 06:06
5

I got the same error. I tried for searching "Use Legacy Swift Language Version", but not found. I am using Xcode 8.3.3 After surfing too much and working around i found this solution, and this worked for me.

Follow these steps.
1=> select your target from Xcode
2=> go to build setting
3=> search for "Swift Language Version"
4=> change it to swift 3. (or accordingly.)

Hope this work for you.

Aklesh Rathaur
  • 1,837
  • 18
  • 19
4

Fixed in Xcode 8.2.1.

Here is a copy of the integrality of the changelog of Xcode 8.2.1:

Swift

Resolved Issues

  • Fixed an issue that could cause building a project to fail with the error message “"Use Legacy Swift Language Version" (SWIFT_VERSION) is required to be configured correctly for targets which use Swift” when using a supported version of Swift. (29667880)
  • Xcode no longer warns about using deprecated Swift 2.3 code when the active scheme does not reference targets using Swift 2.3 code. (29671741)
Community
  • 1
  • 1
Cœur
  • 37,241
  • 25
  • 195
  • 267
3

Close Xcode and open the corresponding project.pbxproj in a text editor of your choice.

Replace SWIFT_VERSION = 3.0.1; with SWIFT_VERSION = 3.0; for all targets.

Reopen Xcode.

Klaas
  • 22,394
  • 11
  • 96
  • 107
3

This is the only thing that worked for me...

For errors with pods. Basically we need to enable “Legacy Swift Language”. Select your pod framework (by clicking on it in the error navigator) and under Build Settings find “Use Legacy Swift Language Version”

enter image description here

Set it to “Yes”. Then “Build & Run” again to test it.

Check out this post: http://rebeloper.com/downgrade-swift-3-swift-2-3-xcode-8/

dianakarenms
  • 2,609
  • 1
  • 22
  • 22
1

Well I've finally figure it out. I've removed the project and clone it again, restarted Xcode, run pod repo update and pod install and it worked. I've no idea why.

Aleš Oskar Kocur
  • 1,381
  • 1
  • 13
  • 29
  • 2
    It's because of the DerivedData folder keeping a cache of previous Xcode builds with sym links. You need to empty the trash while Xcode is closed. – Cœur Dec 13 '16 at 11:14
0

This did not work for us :( reverting back to Xcode 8.1 is best for now until Apple QA's their stuff before they release.

If its any consolation here are things we tried and got us very close. We got stuck at the Clean Failed:

rm -rf ~/Library/Developer/Xcode/DerivedData/ModuleCache

rm -rf ~/Library/Preferences/com.apple.Xcode.plist

restart Xcode and do a deep clean holding the option key

That got rid of the Clean Failed.

Adding this to your pod script

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

That is the way to have all pods conform to 3.0 and we actually got it to build, but at the end of compiling we got this 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.

How do we change the workspace so that all projects conform to swift 3.0? Where is that setting?

Laser Hawk
  • 1,988
  • 2
  • 23
  • 29
0

It turns out that Apple decided to reference a version of the swift language that doesn't exist yet within the pbxprojec file. They hard coded 3.0.1, and by manually editing the sudo XML in the pbx file back to 3.0 everything worked again. Apple apparently overlooked some simple QA work before they released 8.2

This could also explain why toggling between legacy in the build settings worked for some people.

Laser Hawk
  • 1,988
  • 2
  • 23
  • 29
0

I got the same error when converting parts of my app (both Obj C and Swift) to a framework, but in my case it was that the "Swift Language Version" under Build Settings wasn't set. I set it to Swift 3 (the only option), and the error went away.

ScottyB
  • 2,167
  • 1
  • 30
  • 46