如何使除本地Pod以外的所有Pod的警告静音? [英] How can I silence warnings from all pods except local pods?

查看:75
本文介绍了如何使除本地Pod以外的所有Pod的警告静音?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我假设类似

post_install do |installer|

  # Debug symbols
  installer.pod_project.targets.each do |target|
    target.build_configurations.each do |config|
      if ? == ?
        config.build_settings['?'] = '?'
      end
    end
  end

end


推荐答案

我今天遇到了类似的问题,并根据依赖关系的复杂程度,找到了两种解决方法

I encountered a similar problem today and figured out two ways to achieve this depending on the complexity of your dependencies.

第一种方法很简单,如果本地开发容器位于主容器文件中而不嵌套在其他依赖项中,则应该可以使用。基本上照常禁止所有警告,但是在每个本地Pod上指定false:

The first way is simple and should work if your local development pods are in your main pod file and not nested in another dependency. Basically inhibit all the warnings as per usual, but specify false on each local pod:

inhibit_all_warnings!

pod 'LocalPod', :path => '../LocalPod', :inhibit_warnings => false
pod 'ThirdPartyPod',

第二种方法更全面,应该适用于复杂的嵌套依赖项是通过创建本地Pod的白名单,然后在安装后进行操作,禁止任何不属于白名单的Pod的警告:

The second way which is more comprehensive and should work for complex nested dependencies is by creating a whitelist of your local pods and then during post install, inhibit the warnings of any pod that is not part of the whitelist:

$local_pods = Hash[
  'LocalPod0' => true,
  'LocalPod1' => true,
  'LocalPod2' => true,
]

def inhibit_warnings_for_third_party_pods(target, build_settings)
  return if $local_pods[target.name]
  if build_settings["OTHER_SWIFT_FLAGS"].nil?
    build_settings["OTHER_SWIFT_FLAGS"] = "-suppress-warnings"
  else
    build_settings["OTHER_SWIFT_FLAGS"] += " -suppress-warnings"
  end
  build_settings["GCC_WARN_INHIBIT_ALL_WARNINGS"] = "YES"
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      inhibit_warnings_for_third_party_pods(target, config.build_settings)
    end
  end
end

这现在将仅禁止第三方依赖,但将警告保留在任何本地容器上。

This will now only inhibit 3rd party dependencies but keep the warnings on any local pods.

这篇关于如何使除本地Pod以外的所有Pod的警告静音?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆