问题描述
我目前正在将Podfile
中的旧版设置为SWIFT_VERSION = 2.3
,但是我正在使用的某些库是Swift 3.0,这意味着我需要将所有Swift 3.0
Pod旧版的旧版手动设置为pod install上的c3>.如何在Podfile
安装程序中配置每个Pod版本?
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?
这是我要设置的:
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
如果我设置了config.build_settings['SWIFT_VERSION'] = '3.0'
,则说明Swift 2.3
窗格有问题.最好的解决方案是,如果我们分别设置每个Pod旧版本,以避免不得不手动设置它.
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.
推荐答案
我在搜索如何将Xcode 9的SWIFT_VERSION设置为3.2时发现了这一点.
I found this while searching how to set the SWIFT_VERSION to 3.2 for Xcode 9.
使用本身和多个依赖项需要3.2而不是4.0的AirMapSDK,这是一个示例,说明如何为可能遇到此问题的其他人设置特定于pod的SWIFT_VERSION.
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
您可以更改if数组,以指定设置版本所需的任何Pod.
You can change the if array to specify whatever pod you need to set the version too.
这篇关于如何在Podfile中为每个Pod设置旧版Swift版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!