How to set the Legacy Swift Versions for each Pod in Podfile
If you need to manage multiple Swift versions for pods, you can build a mapping.
DEFAULT_SWIFT_VERSION = '4'
POD_SWIFT_VERSION_MAP = {
'Dotzu' => '3'
}
post_install do |installer|
installer.pods_project.targets.each do |target|
swift_version = POD_SWIFT_VERSION_MAP[target.name] || DEFAULT_SWIFT_VERSION
puts "Setting #{target.name} Swift version to #{swift_version}"
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = swift_version
end
end
end
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.