8

I have been getting the following error with Xcode 8.3 in my pure Objective C project.

I have not been able to find a solution for this, there are no swift parameters in my build settings and I can not find any solutions online for this either.

Any Ideas? This was building fine a few days ago, and the only difference I can see is that xcode updated.

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

Rob
  • 1,233
  • 13
  • 24
  • are you using core data the solution is here. https://stackoverflow.com/questions/38446097/xcode-8-beta-3-use-legacy-swift-issue# – Anup Gupta Dec 05 '17 at 08:09
  • Thanks but this was resolved long ago.. appreciate the help anyway though! – Rob Dec 08 '17 at 14:26

2 Answers2

16

So the answer to this is to go to the build settings and click the + icon at the top left (as per screen shot below). Then choose to add a User Defined parameter with SWIFT_VERSION and a value of 3.0. Build the app and it should run fine.

enter image description here

I also added the following to my Pod file too to automatically do the same process for the pod dependency build settings, although this alone did not resolve the problem:

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
Rob
  • 1,233
  • 13
  • 24
  • 2
    I guess you could also create a random `*.swift` file because that should make the Swift settings to appear. – Sulthan Apr 05 '17 at 19:38
  • I would highly recommend against this in a production environment. The codebase is pure Objective C for a reason. If a large development team are working on the project, it is likely someone will remove the seemingly pointless `.swift` file. Not to mention this would be bad practice. The error is introduced due to its dependancies being written in swift. This would be the correct way to resolve the issue. But thanks for the thought all the same :) – Rob Apr 05 '17 at 20:00
  • I meant to create and then delete the file. I believe the act of creation will enable the settings. – Sulthan Apr 05 '17 at 20:12
  • Apologies I am with you now. Yes I suppose this could also be an option, personally I find adding the one needed setting is less 'overkill', but that might be just personal preference. – Rob Apr 05 '17 at 20:14
  • if we delete that swift file, the swift version settings are disappeared. – R. Mohan Nov 27 '17 at 12:01
3

Click On Pods Project under Project Navigitor, and go to build settings search for swift_version then change swift language version to Swift 4.0

Pods>BuildSettings>Swift Language Version>Swift 4.0

enter image description here

Smart guy
  • 494
  • 6
  • 9