Xcode 8 Beta 3 Use Legacy Swift issue

SwiftXcode8Xcode8 Beta3

Swift Problem Overview


I have an Objective-C project in Xcode 8 Beta 3. Since updating, whenever I try to build I receive 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.

Has anyone encountered this? Since it's an Objective-C project there's no build setting to configure Swift. I have also made sure none of the project dependencies or CocoaPods are using Swift. The only solution I have is to use Beta 2. Any ideas how I might fix this issue?

I should also mention I'm running OSX 10.12 Beta 2.

Swift Solutions


Solution 1 - Swift

If you are using CocoaPods and want it to be fixed automatically every time you are doing a pod install, then you can add these lines to 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

EDIT: This problem is now fixed if you use CocoaPods v1.1.1 or later. Don't forget to remove the ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES setting from your main project targets.

Solution 2 - Swift

I just found a way to fix it.

Go to the Build settings of the project or library and set the Swift Compiler Version attribute "Use Legacy Swift Language Version" from Unspecified to Yes or NO.

enter image description here

Solution 3 - Swift

I have been ignoring this problem for a while now and just working on other stuff in the meantime - I finally found the solution to my problem.

Since my project is Objective-C I figured maybe one of the Pods I am using was using Swift, I checked each Pod and none of them were.

The final solution was that my Core Data model was set to generate code in Swift even though I have been manually generating them in the File > New > NSManagedObjectSubclass menu. All I had to do was switch it to Objective-C.

screenshot

Solution 4 - Swift

This issue is also visible in Xcode-8.1 . When we add new Target like Extension or Widget and Third party library is integrated in new target with the help of cocopods. After Pod install . We can face same error as above .

Change the Use Legacy Swift Language Version in every Library Build Setting to

> No.

enter image description here

Solution 5 - Swift

If you are using Xcode 8 or later

  1. Go to Build Settings
  2. Find use legacy swift language version
  3. Yes - Swift 2.3
  4. No - Swift 3.0 enter image description here

Solution 6 - Swift

Add below code in end of the 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

Solution 7 - Swift

I'm working on a project which has mixed objective-c and swift code I previously used swift version 2.3 and after upgrading to swift 3 I was unable to build the project. Xcode complained with the mentioned error message.

Apparently, there was still some outdated Swift version specified in my project.pbxproj file. There was swift 3.0.1 specified:

SWIFT_VERSION = 3.0.1;

Whereas, I already had 3.0.2 installed:

$ xcrun swift -version
Apple Swift version 3.0.2 (swiftlang-800.0.63 clang-800.0.42.1)
Target: x86_64-apple-macosx10.9

Sooo, I fixed it by changing the Swift version in the project-pbxproj file to:

SWIFT_VERSION = 3.0;

Seems the patch level version specifier was too specific.

Solution 8 - Swift

In my case I have Just do the Following things

Choose project Target=>Go to Build setting=>Search for “Swift Language Version” =>give Value the current Swift version

Thats all It has fixed my Issue

Follow This Image

Solution 9 - Swift

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.enter image description here

Here are the 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.)

Solution 10 - Swift

set "Use Legacy Swift Language Version" to "YES" if you using a old version of swift in your project or any swift 3rd party. "No" if your project uptodate to current swift version. if you don't configure your swift version , after every update and Install, Pod framework need to specify this.

Solution 11 - Swift

I actually had to do a search for "Legacy Swift" to be able to change it from unspecified to "Yes" When I simply scrolled down to the section described above, I was not able to change it. I hope this will help someone.

Solution 12 - Swift

My project is written in Swift. I got that same error with fastlane. What happened was my Xcode auto-updated so I had to update my project to Swift 3.0. Got a ton of errors. Fixing and debugging was taking too much time and it was not worth it at that moment so I decided to install an older version of Xcode. Reverted my code to 2.3. Then fastlane beta wasn't working anymore. Turns out, I needed to set the Command Line Tool to 7.3. enter image description here

Solution 13 - Swift

If you change ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES to NO still not work, it is because the xcode issue, not your problem. Doing the follow steps:

1.Change ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES property to be YES on the warning target

2.then it will show an warning on left bar which recommend you change to swift 3.0

3.then change back to NO. Rebuild the project, the xcode finally detect your change to NO!

Problem solved in this case!

Solution 14 - Swift

I was having this same issue and solved it by doing the following:

In Project > Build Settings:

Always Embed Swift Standard Libraries = $(inherited) Use Legacy Swift Language Version = YES

Then in my Podfile:

config.build_settings['SWIFT_VERSION'] = '3.0'

Using these three settings removed all warnings and allowed me to compile properly.

The most obscure and what actually got progress for compiling was changing the SWIFT_VERSION in the Podfile from 3 to 3.0 as suggested here.

Solution 15 - Swift

From XCode 8 onwards, 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, then XCode will use Swift 2.3 for that project target.

Solution 16 - Swift

Before trying complicated solutions, here is a basic check you need to do if you are new to Cocoapods and you are having this issue.

You might need to:

  • Open your Podfile again
  • Check that the line for platform is not commented out with a '#'. It should finally look like something like :

platform :ios, '10.1' # Put the right version and no #platform here use_frameworks! # For swift pod "MyPod" # Your mean pod :)

  • Save your Podfile, Close Xcode, and Run pod install again
  • Open your project.xcworkspace

Maybe it's just that.

If not, you can go above ;-)

Solution 17 - Swift

I had this same problem after updating to xcode 8.3.2 but the option "Use Legacy Swift Language" was gone. This seems to be the option to change now: Swift Lang Version

Used this fix with Alamofire and other libs and all works ok.

Solution 18 - Swift

Go to Project Build Setting for project and Target do below two.

ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES
And
Swift Compiler - Version  = Swift 3

Change to latest Swift 3.

Error resolved.

If it's resolved your error fix, please like it.

Solution 19 - Swift

In Xcode 9 beta. Go to Project Settings, Build Settings, search for Swift Language Version. In Xcode 9 you must specify if you are using Swift 3.2 or Swift 4.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionBryanView Question on Stackoverflow
Solution 1 - SwiftTullebView Answer on Stackoverflow
Solution 2 - SwiftrockdaswiftView Answer on Stackoverflow
Solution 3 - SwiftBryanView Answer on Stackoverflow
Solution 4 - SwiftShrawanView Answer on Stackoverflow
Solution 5 - SwiftMohammad Kamran UsmaniView Answer on Stackoverflow
Solution 6 - SwiftSunil aruruView Answer on Stackoverflow
Solution 7 - SwiftleviathanView Answer on Stackoverflow
Solution 8 - Swiftkhusboo suhasiniView Answer on Stackoverflow
Solution 9 - SwiftAklesh RathaurView Answer on Stackoverflow
Solution 10 - SwiftMohammad ArifuzzamanView Answer on Stackoverflow
Solution 11 - SwiftMountain ManView Answer on Stackoverflow
Solution 12 - SwiftyoninjaView Answer on Stackoverflow
Solution 13 - SwiftWangdu LinView Answer on Stackoverflow
Solution 14 - SwiftHector PartidasView Answer on Stackoverflow
Solution 15 - Swiftarunjos007View Answer on Stackoverflow
Solution 16 - SwiftDiphazeView Answer on Stackoverflow
Solution 17 - SwiftJorge IrúnView Answer on Stackoverflow
Solution 18 - SwiftkiranView Answer on Stackoverflow
Solution 19 - SwiftNiall KehoeView Answer on Stackoverflow