如何使用Swift 3中的Pod使用Swift 4.0构建xcode 9项目?
我希望我的iOS应用程序的主模块编译雨燕4.0,而的CocoaPods模块编译迅速3.如何使用Swift 3中的Pod使用Swift 4.0构建xcode 9项目?
PS:使用Xcode的9测试版2.
最后我得到它的工作:我所要做的就是把这个脚本Podfile的末尾:
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '3.2'
end
end
end
设置雨燕4.0,除了框架所有的这些目标要雨燕3.2
这就是我正在做的一个项目
如果您使用写在斯威夫特4一些豆荚,但有些是雨燕3.2,这里是你可以指定他们SWIFT_VERSION价值的方式:
swift_32 = ['Pod1', 'Pod2', 'Pod3'] # if these pods are in Swift 3.2
swift4 = ['Pod4', 'Pod5', 'Pod6'] # if these pods are in Swift 4
post_install do |installer|
installer.pods_project.targets.each do |target|
swift_version = nil
if swift_32.include?(target.name)
swift_version = '3.2'
end
if swift4.include?(target.name)
swift_version = '4.0'
end
if swift_version
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = swift_version
end
end
end
end
这应该是公认的答案,因为它允许修订,因为库已更新到Swift 4. – MandisaW
项目导航>选择“窗格”>选择Swift 3.2 Pod>'Build Settings'>向下滚动,然后在'Swift Compiler - Language section'中将Swift Language Version设置为3.2。
在执行此操作时,Xcode将显示一个Buildtime问题。它会要求你将Pod的源代码转换成Swift 4.不要那样做。点击该问题>取消选中“提醒我”>点击“稍后转换”。
项目导航
构建设置
迄今为止最简单的答案(Y) –
我喜欢这个答案,你好吗? – fullMoon
这是一种较详细的方式来设定你需要3.2舱体,并留下所有其他在4.0
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
J最后修改if语句中的数组。一切将默认为4.0
也与我一起工作。但是您需要每次按下构建才能生效,并且错误消息将消失。 –