19

When i opened my project into Xcode 8 then I got 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

referring to a similar post on StackOverflow , Use Legacy Swift Language Version YES/NO . But it's not working for me either by doing YES or No value ?

Please help.

I have checked Use Legacy Swift Language Version to options YES/NO please check attached screenshot Use Legacy Swift Language Version-YES

Use Legacy Swift Language Version-NO

Community
  • 1
  • 1
rakex
  • 1,999
  • 2
  • 16
  • 17

5 Answers5

16

Add this to your pod-file:

# Uncomment this line to define a global platform for your project
platform :ios, '9.0'
# Uncomment this line if you're using Swift
use_frameworks!

target 'yourappname' do

pod 'yourpodlists'

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

Run pod-install again. Clean your project with cdm + alt + shift + k. Clean again using cmd + shift + k. Restart Xcode. Build. Now it should work.

If you're not using cocoapods, you should be able to fix this issue by setting the Compiler Version attribute Use Legacy Swift Language Version from unspecified to Yes or No.

Build settings of the project or library ->

enter image description here

David Seek
  • 16,783
  • 19
  • 105
  • 136
2

try converting swift code to swift3 or swift 2.3. edit -> convert -> to current swift-> select swift 3 or swift 2.3. This will works.

Savitha
  • 561
  • 6
  • 19
  • I have tried to convert code in swift3 or swift 2.3 its still giving me compilation errors – rakex Sep 22 '16 at 07:04
  • please check edited question..I have attached screenshots – rakex Sep 22 '16 at 11:40
  • After conversion, some api needs wrapping and unwrapping changes as per xcode 8. As per your screen shot all those changes is in one classes. Please do those changes and hope that will solve your problem. – Savitha Sep 22 '16 at 11:52
  • After conversion, Legacy Swift Language Version will set by xcode only. so no need of changing afterwards – Savitha Sep 22 '16 at 11:53
  • there are changes in so many classes after conversion to swift. Are you saying that I have to change individual files code for the conversion as Xcode is unable to do it? – rakex Sep 23 '16 at 05:36
2

enter image description hereI am using Xcode 8.3.3 After surfing too much and working around i found this solution, and this worked for me.

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.)
Aklesh Rathaur
  • 1,837
  • 18
  • 19
0

As reference to this, This is what I've concluded (for Xcode 8) :

  1. If your code is in swift version = 2.3 then you just need to set Use Legacy Swift Language Version to YES in build setting and you will good to go.
  2. If your code is in swift version < 2.3 then :

    i) convert your code to swift 2.3 and Set 'Use Legacy Swift Language Version = YES'

    OR

    ii) convert your code to latest swift version (might be 3.0) and Set 'Use Legacy Swift Language Version = NO'

In my case, I've used external library which was in swift 2.2 causing errors in Xcode 8.0, so I replace the same library with swift version 2.3 and used above solution 2.i). Now everything is fine.

Hope this help someone who are seeking the solution to this problem.

iAkshay
  • 1,143
  • 1
  • 13
  • 35
0

If you're not using pods just add this to your Info.plist - I'm on 2.3enter image description here

as the option wasn't listed in build settings.

slashlos
  • 913
  • 9
  • 17