【发布时间】:2018-03-25 03:24:15
【问题描述】:
【问题讨论】:
标签: swift xcode cocoapods xcode9
【问题讨论】:
标签: swift xcode cocoapods xcode9
您可以在每次运行 pods install 时自动启用此功能,方法是将以下 post_install 脚本添加到 Podfile 的末尾。
post_install do |installer|
installer.pods_project.build_configurations.each do |config|
if config.name == 'Release'
config.build_settings['SWIFT_COMPILATION_MODE'] = 'wholemodule'
end
end
end
在旧版本的 Xcode 中,您将需要:
post_install do |installer|
installer.pods_project.build_configurations.each do |config|
if config.name == 'Release'
config.build_settings['SWIFT_OPTIMIZATION_LEVEL'] = '-Owholemodule'
else
config.build_settings['SWIFT_OPTIMIZATION_LEVEL'] = '-Onone'
end
end
end
【讨论】:
使用整体模块优化允许编译器查看所有 模块中的源文件。这会使编译速度变慢但允许它 优化通用函数,即使它们位于不同的源中 文件。您可以在执行时间的最终测试运行中看到这一点 现在本地和外部函数定义都是一样的。
总之,如果您不介意额外的编译时间,请尝试转 关于您的发布版本的整个模块优化。
这个source 应该让您更深入地了解全模块优化
Xcode 对 Pods 项目所做的任何更改都将在您下次运行 pod install 时被吹走,因此必须在 Cocoapods 中进行更新才能消除此警告。有一个关于这个here的讨论。
短期解决方案是将post_install 脚本添加为Mike suggested。
【讨论】: