San*_*0rd 19 ios cocoapods swift3 swift4 xcode9-beta
我想我的iOS App的主模块编译Swift 4.0,而CocoaPods模块编译swift 3.
PS:使用Xcode 9 beta 2.
bub*_*uxu 17
如果你使用的是一些用Swift 4编写的pod,但有些是Swift 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
Run Code Online (Sandbox Code Playgroud)
San*_*0rd 16
最后我得到了它的工作:我所要做的就是将这个脚本放在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
Run Code Online (Sandbox Code Playgroud)
Jus*_*ler 12
这是一个远远不那么详细的方法来设置你需要的pod 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
Run Code Online (Sandbox Code Playgroud)
只需修改if语句中的数组即可.其他一切都默认为4.0
小智 9
Project Navigator>选择'Pods'>选择Swift 3.2 Pod>'Build Settings'>向下滚动,然后在'Swift Compiler - 语言部分'中将Swift语言版本设置为3.2.
在这样做时,Xcode将显示一个Buildtime问题.它会要求你将pod的源代码转换为Swift 4.不要这样做.单击该问题>取消选中"提醒我">单击"稍后转换".
项目导航器
构建设置
| 归档时间: |
|
| 查看次数: |
7159 次 |
| 最近记录: |