Cocoapods warnings tips

A short tip for people using Cocoapods. Because of how Pods are working (or should be used as in you don''t edit anything in Pods since it can be overwritten when you use pod install) it's extremely annoying (to me) when I see warnings for Pods project which I can't fix. As a good sport you should always try to get no warnings when compiling your projects and getting those from code you can''t (or shouldn''t really, at least directly in your project) fix makes that impossible.

This can easily lead to just ignoring warning you should pay attention to (in your own code). Here's an easy fix for that.

Pods have pre-install and post-install hooks you can use to do a lot of things - one of which is modify Pods projects file. With that in mind there''s an "Inhibit All Warnings" compiler flag we can use to suppress warnings from Pods project. All you have to do is to add these few lines of code to your Podfile and do the usual pod install:

post_install do |installer_representation|
  installer_representation.project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings[''GCC_WARN_INHIBIT_ALL_WARNINGS''] = 'YES'
    end
  end
end

UPDATE

As Eloy DurĂ¡n (creator of Cocoapods) pointed out on twitter - you can also use a shorter method of just adding inhibit_all_warnings! or even set that per Pod with: pod 'SSZipArchive', :inhibit_warnings => true

Posted on
Tagged in tips , cocoapods
Jarek Pendowski

Want to talk?

comments powered by Disqus