How can I silence warnings from all pods except local pods?

前端 未结 3 1493
太阳男子
太阳男子 2021-02-18 17:12

I\'m assuming something along the lines of

post_install do |installer|

  # Debug symbols
  installer.pod_project.targets.each do |target|
    target.build_conf         


        
相关标签:
3条回答
  • 2021-02-18 17:49

    Podfile Solution

    While ignore_all_warnings is an all or none proposition, you can :inhibit_warnings => true on any individual pod in the Podfile.

    # Disable warnings for each remote Pod
    pod 'TGPControls', :inhibit_warnings => true
    
    # Do not disable warnings for your own development Pod
    pod 'Name', :path => '~/code/Pods/' 
    
    0 讨论(0)
  • 2021-02-18 17:51

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

    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',
    

    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.

    0 讨论(0)
  • 2021-02-18 17:58

    There's CocoaPods plugin, https://github.com/leavez/cocoapods-developing-folder that has inhibit_warnings_with_condition. Citing the README:

    0 讨论(0)
提交回复
热议问题