How to Set the Legacy Swift Versions for Each Pod in Podfile

How to set the Legacy Swift Versions for each Pod in Podfile

I found this while searching how to set the SWIFT_VERSION to 3.2 for Xcode 9.

Using the AirMapSDK which itself and multiple dependencies need 3.2 instead of 4.0 Here is an example of how to set pod specific SWIFT_VERSION for others that may come across this question.

post_install do |installer|
installer.pods_project.targets.each do |target|
if ['AirMapSDK', 'PhoneNumberKit', 'Lock', 'RxSwift', 'RxSwiftExt', 'RxCocoa', 'RxDataSources', 'ProtocolBuffers-Swift'].include? target.name
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '3.2'
end
end
end
end

You can change the if array to specify whatever pod you need to set the version too.

How to define the swift version for a specific pod in a Podfile

post_install do |installer|
installer.pods_project.build_configurations.each do |config|
config.build_settings.delete('CODE_SIGNING_ALLOWED')
config.build_settings.delete('CODE_SIGNING_REQUIRED')
end
installer.pods_project.targets.each do |target|
if ['SideMenuController'].include? target.name
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '3.0'
end
end
end
end

How to set up versions for specific pods in Podfile?

You should use symbols against values. Updated code is below:

post_install do |installer|
installer.pods_project.targets.each do |pod|
pods = {'CDMarkdownKit': '4.0', 'MessageKit': '4.0', 'LocalizationKit': '4.0', 'RxKeyboard': '4.0', 'JWTDecode': '3.1'}
if pods.has_key?(pod.name.to_sym)
pod.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = pods.values_at(pod.name.to_sym)
end
end
end
end

Error when upgrade pod file to new swift version

Update Your Xcode to 10.2 or manually set versions in pod as following

pod 'Eureka',  '~> 4.3.1'

When you keep pod in podfile, cocoapods installs latest version of the library.
In your case, the latest version is written in Swift 5, but your xcode does not support Swift 5, you must set the pod version for installing lib with the supported version of swift.

Swift version required by a Pod?

You can try terminal command,

pod try "pod name" 

this will clone the repo automatically for you to test the framework on the fly
there you can check out whatever you need.

Plus reading the description on GitHub helps too

Also i recommend using highly popular pods, as they tempt to be more stable.

read the reviews about the framework, and try to find other alternatives for it.

New update: You can try to preview .podspec file inside the Repo on github sometimes you can find the Swift Version of that Pod example : here

Xcode 8 Beta 3 Use Legacy Swift issue

I have been ignoring this problem for a while now and just working on other stuff in the meantime - I finally found the solution to my problem.

Since my project is Objective-C I figured maybe one of the Pods I am using was using Swift, I checked each Pod and none of them were.

The final solution was that my Core Data model was set to generate code in Swift even though I have been manually generating them in the File > New > NSManagedObjectSubclass menu. All I had to do was switch it to Objective-C.

screenshot

Cocoa pod installation error: The target overrides the SWIFT_VERSION build setting

It is a bit non-intuitive but what you have to do is:

1) Search for "SWIFT_VERSION" in your project settings

2) you will see an entry saying "Use Legacy Swift Language Version"

  • If you had already selected any value it will be shown in BOLD

3) Select the entry (not the value) and press "DELETE", the boldness should disappear.

4) Repeat the same steps but now for your target (the one with the app icon)

5) Close XCode

6) Run "pod install" again

7) Open your project, and CLEAN IT (Shift + Command + K)

Now it should be working correctly.

NOTE:

Specifically for "Cocoalumberjack" make sure your pod is installing the 3.0+ version, if its not run a "sudo pod update" as versions previous to this won't work with Swift 3.

EDIT:

I'm pretty sure the cocoapods handling of this is a bit buggy at the moment, as I've experienced sometimes it works and others it doesnt. However, keep in mind you can set the "SWIFT_VERSION" flag directly on a per framework basis:

1) Select the Pods project (within your project).

2) Select the target that you want to set and look for the "SWIFT_VERSION" flag specifically for that target.

3) Clean and rebuild.



Related Topics



Leave a reply



Submit