“Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use Swift

24,032

Solution 1

In the navigator selection bar, click the magnifying glass, then search for "SWIFT_VERSION" You will find the places in the project where you can adjust the swift version accordingly.

enter image description here

enter image description here

Solution 2

You can't. XCode 8.2 was the last version to support Swift 2.3. You have to either update to Swift 3 or use Xcode 8.2.

Solution 3

In My case I selected Pod and changed swift version for specific pod. This works for me.

enter image description here

Solution 4

To programmatically change swift version of pods, you may add this inside your Podfile

post_install do |installer|
    installer.pods_project.targets.each do |target|
        if ['Alamofire','OtherPod','AnotherPod'].include? target.name
            target.build_configurations.each do |config|
                config.build_settings['SWIFT_VERSION'] = '4.0'
            end
        end
    end
end

In Swift 4, if you are using objective-c as well,

you may turn on @objc inference so the swift project will run properly on objective-c.

post_install do |installer|
    installer.pods_project.targets.each do |target|
        if ['Alamofire','OtherPod','AnotherPod'].include? target.name
            target.build_configurations.each do |config|
                config.build_settings['SWIFT_SWIFT3_OBJC_INFERENCE'] = 'On'
            end
        end
    end
end

Solution 5

Damn you Xcode, now I have to migrate to Swift 3.0. It clearly shows up this alert on opening or building an old project with Swift 2.3 so I suggest lets migrate :( :(

enter image description here

Share:
24,032
ΩlostA
Author by

ΩlostA

Développer iOS/Android at NewTelApps

Updated on July 05, 2022

Comments

  • ΩlostA
    ΩlostA almost 2 years

    I just did the last Xcode update (8.3), and I have the message :

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

    Knowing that the "Use Legacy Swift Language Version" option has just been removed from the build settings, how can I generate my app in Swift 2.3 without doing any conversion for now ?