Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

cocoapods

I'm assuming something along the lines of

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
like image 404
hfossli Avatar asked Jul 27 '15 04:07

hfossli


2 Answers

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.

like image 55
Bryant Balatbat Avatar answered Nov 09 '22 14:11

Bryant Balatbat


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/' 
like image 39
SwiftArchitect Avatar answered Nov 09 '22 15:11

SwiftArchitect