Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I am currently setting the legacy in the Podfile to SWIFT_VERSION = 2.3, but some of the libraries I am using are Swift 3.0, which means that I need to manually set the legacy for all Swift 3.0 pods legacy to No on each pod install. How do I configure each pod version in the Podfile installer?

This is what I am setting:

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 

If I set config.build_settings['SWIFT_VERSION'] = '3.0', than we have issues with Swift 2.3 pods. The best solution is if we set each pod legacy version separately to avoid having to manually set it.

like image 612
Tal Zion Avatar asked Nov 09 '16 06:11

Tal Zion


People also ask

How do I specify pod version in Podfile?

<Specifying pod versions Later on in the project you may want to freeze to a specific version of a Pod, in which case you can specify that version number. Besides no version, or a specific one, it is also possible to use logical operators: '> 0.1' Any version higher than 0.1. '>= 0.1' Version 0.1 and any higher version.

How do I update the Swift pod in IOS?

TL;DR: Use pod install to install new pods in your project. Even if you already have a Podfile and ran pod install before; so even if you are just adding/removing pods to a project already using CocoaPods. Use pod update [PODNAME] only when you want to update pods to a newer version.


1 Answers

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.

like image 191
Justin Miller Avatar answered Nov 05 '22 18:11

Justin Miller