user2526811
user2526811

Reputation: 1253

Use Legacy Swift Language Version” (SWIFT_VERSION) is not working

I have a app with swift version 2.3.

When I try to run in xcode 8 with set "User Legacy Swift -> YES" in build setting, it give me errors for cocoapods only.

see below image:

enter image description here

MY pod file:

 platform :ios, '8.0'
 use_frameworks!

target 'xxx' do
pod 'Alamofire', '~> 3.3'
pod 'PKHUD', '~> 3.1'
pod 'SCLAlertView', '~> 0.5'
pod 'SwiftyJSON', '~> 2.3'
pod 'ICSPullToRefresh', '~> 0.4'
pod 'ReachabilitySwift', '~> 2.3'
pod 'IQKeyboardManagerSwift', '~> 4.0'

end

target 'xxTests' do

end

target 'xxUITests' do

end


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

Upvotes: 3

Views: 5020

Answers (2)

dianakarenms
dianakarenms

Reputation: 2695

This is the only thing that worked for me...

Note that this error is currently in a pod, but could be anywhere in your project tree. I’m going to show you how to “allow” Swift 2.3 in this pod. Basically we need to enable “Legacy Swift Language”. Select your pod framework (by clicking on it in the error navigator) and under Build Settings find “Use Legacy Swift Language Version”

enter image description here

Set it to “Yes”. Than “Build & Run” again to test it.

Check out this post: http://rebeloper.com/downgrade-swift-3-swift-2-3-xcode-8/

Upvotes: 2

jarora
jarora

Reputation: 5762

This basically means that the pods are built for different swift version than your current project.

In my case my app migrated to Swift 3 but my pods remained on Swift 2.3 because they haven't adapted to Swift 3 yet. You can do either of the two things here:

  1. Change your pods to Swift 3 (or whatever latest Swift version) by going to Edit > Convert > To Current Swift Syntax.
  2. Degrade your main project back to older version of Swift.

I hope this sheds some light on the issue.

Upvotes: 2

Related Questions