【问题标题】:Project 'Pods' - Turn on Whole Module Optimization项目 'Pods' - 打开整个模块优化
【发布时间】:2018-03-25 03:24:15
【问题描述】:

在 Xcode 9 中,我收到以下关于可可豆荚项目的建议:

它有什么作用?而且,我应该打开它,否则它会破坏一切?

【问题讨论】:

    标签: swift xcode cocoapods xcode9


    【解决方案1】:

    您可以在每次运行 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
    

    【讨论】:

      【解决方案2】:

      使用整体模块优化允许编译器查看所有 模块中的源文件。这会使编译速度变慢但允许它 优化通用函数,即使它们位于不同的源中 文件。您可以在执行时间的最终测试运行中看到这一点 现在本地和外部函数定义都是一样的。

      总之,如果您不介意额外的编译时间,请尝试转 关于您的发布版本的整个模块优化。

      这个source 应该让您更深入地了解全模块优化

      Xcode 对 Pods 项目所做的任何更改都将在您下次运行 pod install 时被吹走,因此必须在 Cocoapods 中进行更新才能消除此警告。有一个关于这个here的讨论。

      短期解决方案是将post_install 脚本添加为Mike suggested

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-11-19
        • 2017-11-05
        • 1970-01-01
        • 2013-01-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多