Xcode 8 Beta 3 Use Legacy Swift issue

Bryan picture Bryan · Jul 18, 2016 · Viewed 97.9k times · Source

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.

Answer

Tulleb picture Tulleb · Jul 19, 2016

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.