Use Legacy Swift Language Version - Xcode 8.2

折月煮酒 提交于 2019-11-30 11:57:12

问题


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


回答1:


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.




回答2:


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.




回答3:


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)



回答4:


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.




回答5:


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”

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/




回答6:


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.




回答7:


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?




回答8:


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.




回答9:


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.



来源:https://stackoverflow.com/questions/41118912/use-legacy-swift-language-version-xcode-8-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!