Skip to content

“Use Legacy Swift Language Version” with pod 'Alamofire', '~> 4.0' #1526

@anilios

Description

@anilios

I have to convert my project from XCode 7 to 8. But and i have following in my pod file: pod 'Alamofire', '~> 4.0'

And i get this error on compilation.

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

How to fix this.

Activity

Jeyhey

Jeyhey commented on Sep 14, 2016

@Jeyhey

Have the same error

adrimarti

adrimarti commented on Sep 14, 2016

@adrimarti

Same here

ostatnicky

ostatnicky commented on Sep 14, 2016

@ostatnicky

Have you tried this? http://stackoverflow.com/a/38466703/1054550

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
Jeyhey

Jeyhey commented on Sep 14, 2016

@Jeyhey

Thanks! Worked for me. Hope there are no side-effects.

antsmo

antsmo commented on Sep 14, 2016

@antsmo

I'm having the same issue and the above fix resulted in:

Module file was created by an older version of the compiler; rebuild 'Alamofire' and try again:
.../path/to/Alamofire.framework/Modules/Alamofire.swiftmodule/arm64.swiftmodule

Here's my Podfile if it helps..

platform :ios, '9.0'
use_frameworks!

target 'my-project' do

  pod 'Firebase'
  pod 'Firebase/Auth'
  pod 'Firebase/Messaging'
  pod 'ChameleonFramework/Swift', :git => 'https://github.com/ViccAlexander/Chameleon.git', :branch => 'swift3'
  pod 'SwiftyJSON', :git => 'https://github.com/acegreen/SwiftyJSON.git', :branch => 'swift3'
  pod 'Alamofire', '~> 4.0'

end

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: Seem to have fixed it by deleting my app's entry in DerivedData and cleaning the project

jshier

jshier commented on Sep 14, 2016

@jshier
Contributor

@ostatnicky's workaround should not be necessary if you're using CocoaPods 1.1.0, as it adds that setting to your Pods project automatically. As with any upgrade of Xcode and dependencies, clearing your DerivedData folder is always a good idea.

amirpervaiz086

amirpervaiz086 commented on Sep 21, 2016

@amirpervaiz086

Hi,
I even deleted derived folder added above code in Podfile but still getting same 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."

What exactly need to change?

Thanks,
Amir

mengheangrat

mengheangrat commented on Sep 22, 2016

@mengheangrat

@amirpervaiz086 update your cocoapods

  1. sudo gem install cocoapods --pre
  2. pod install

13 remaining items

yinseng2001

yinseng2001 commented on Sep 25, 2016

@yinseng2001

i try this , and it work for me.

platform :ios, '9.0'
use_frameworks!

target 'mkhPush' do
pod 'Alamofire', '~> 3.3'
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

mfaani

mfaani commented on Oct 12, 2016

@mfaani

See this link. He explains, what's going on in detail. And how to fix it.

techverx

techverx commented on Feb 2, 2017

@techverx

@ostatnicky's solution worked for me too.

Eddiegooo

Eddiegooo commented on Feb 27, 2017

@Eddiegooo

happen to the same problem! must i update my cocoapods to 1.1.0 version to solve this problem?..
who can help me? tks

OK! i have solved it!
you can read Swift开发使用Cocoapods引入第三方库异常处理方法

kumararvind

kumararvind commented on Mar 17, 2017

@kumararvind

I just do Edit->Convert->Current Swift Syntax and error has gone. I did't make any changes in code or Xcode.

It works for me.

added a commit that references this issue on Jul 10, 2017
b7d1c52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @jshier@ostatnicky@anilios@cnrblm@techverx

        Issue actions

          “Use Legacy Swift Language Version” with pod 'Alamofire', '~> 4.0' · Issue #1526 · Alamofire/Alamofire