Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to remove compiler warnings on Pods project? #209

Closed
yas375 opened this issue Apr 15, 2012 · 41 comments
Closed

How to remove compiler warnings on Pods project? #209

yas375 opened this issue Apr 15, 2012 · 41 comments
Assignees

Comments

@yas375
Copy link
Contributor

yas375 commented Apr 15, 2012

I wouldn't see warning from some pods in my workspace.

Here is my Podfile:

platform :ios

dependency 'AFNetworking', '0.9.0'
dependency 'JSONKit'
dependency 'ZBarSDK'
dependency 'DTCoreText', :podspec => 'https://raw.github.com/gist/2282812/3844e5d01f562e1cf67f74b966030f2baae94e6d/gistfile1.txt'

And when I build my application Pods project also compiled every time. Is it good? Or I missed something?

Thanks.

@alloy
Copy link
Member

alloy commented Apr 15, 2012

Regarding the warnings, can you give me a list of all the build settings required to silence those? It’s probably time to add an option to the Podfile that will set those settings.

Regarding Xcode compiling the library every time, I personally have not noticed this. Afaik the first build takes longer than subsequent ones, but I could be wrong. This would be an Xcode issue, though.

@yas375
Copy link
Contributor Author

yas375 commented Apr 16, 2012

I found one interesting build property: GCC_WARN_INHIBIT_ALL_WARNINGS. If I set it to yes, warnings are disappear. Is it you good solution?

btw, in this twit you have mentioned post_install hook:

@yas375 Hmm, then it works differently than I thought… Add a post_install hook to your Podfile which adds the setting to Pods.xcodeproj?

Does it mean that I could set value for GCC_WARN_INHIBIT_ALL_WARNINGS in my podfile now? And it will be used in Pods project? How I should do this?)

Regarding Xcode compiling the library every time, I personally have not noticed this.

does it mean that in your projects pods compiled only once? What version of xcode and cocoapods do you use?

@alloy
Copy link
Member

alloy commented Apr 16, 2012

I found one interesting build property: GCC_WARN_INHIBIT_ALL_WARNINGS. If I set it to yes, warnings are disappear. Is it you good solution?

That sounds like a good enough solution yes. Let’s add this in 0.6.1.

Does it mean that I could set value for GCC_WARN_INHIBIT_ALL_WARNINGS in my podfile now? And it will be used in Pods project? How I should do this?)

Something like this should do the trick:

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

(If you are using cocoapods 0.5.1, then build_configurations and build_settings should be camel cased: buildConfigurations and buildSettings.

@yas375
Copy link
Contributor Author

yas375 commented Apr 16, 2012

cool! It works now with this post_install hook! thanks! =)

@fabiopelosin
Copy link
Member

I think that the pods should not generate warnings. I think that the warnings should be suppressed by the podspec and the library maintainer should be asked to suppress them.

@yas375
Copy link
Contributor Author

yas375 commented May 17, 2012

I agree with you)

@yas375 yas375 closed this as completed Jun 4, 2012
@yas375
Copy link
Contributor Author

yas375 commented Jun 7, 2012

@irrationalfab how current version should be working? As I see warnings from Pods not preventing now. Should it be fixed in current version? Or should I open a new ticket for this?

btw, warnings presence could be checked with MTStatusBarOverlay pod. I got at least 3 warnings with this pod.

@fabiopelosin
Copy link
Member

The podspec needs to update with the appropriate compiler flags that silence the warnings.

@fabiopelosin
Copy link
Member

@yas375
Copy link
Contributor Author

yas375 commented Jun 7, 2012

Should I do this for all specs where I meet warnings? It's not very clear imho. Than I prefer @alloy's method with post_install hook.

Maybe it will be good to disable pods warnings from podfile in this way:

platform :ios

silent_warnings!

dependency 'MTStatusBarOverlay'

Or maybe better to disable warnings by default and enable only if enable_warnings! call presents in Podfile.

What do you think guys?

@fabiopelosin
Copy link
Member

Reasonable point lets see @alloy opinion on this.

@alloy
Copy link
Member

alloy commented Jun 7, 2012

Yeah I do think we should be able to just disable them all in one go like with silence_warnings!. This also makes it very easy for a user to see what warnings it actually generates and possibly provide a patch to the author to fix it.

@alloy alloy reopened this Jun 7, 2012
@yas375
Copy link
Contributor Author

yas375 commented Jun 7, 2012

I could do this. But I will have time only on next week (or even after next week). When release 0.6 should be released?

@alloy
Copy link
Member

alloy commented Jun 7, 2012

Well, this is more of a feature, so it shouldn't even really be added before 0.6.0, as we should not add features during RCs imo. But any time thereafter is fine, see https://github.com/CocoaPods/CocoaPods/wiki/Release-process.

@ghost ghost assigned yas375 Jun 7, 2012
@yas375
Copy link
Contributor Author

yas375 commented Jun 7, 2012

Ok, assigned to me)

@prnewman
Copy link

I get the same compiler warnings as yas375 after adding the ZBarSDK Podspec to my project:

https://github.com/CocoaPods/Specs/blob/master/ZBarSDK/1.2.2/ZBarSDK.podspec

Inhibiting all warnings for the entire Pods project doesn't seem like an ideal solution. I'd prefer contacting the author for a patch before accepting the Podspec.

@fabiopelosin
Copy link
Member

After experiencing a bit with warnings I think that the best solution would be to add GCC_WARN_INHIBIT_ALL_WARNINGS by default. Disabling single warnings categories of warnings in the podspecs is a moving target as the default warnings may change and do not represent the view of the author of the library.

To enable the warnings to see if they meet the needs of the standards of the final user we should add the enable_warnings method in the pod file.

@alloy What do you think?

@alloy
Copy link
Member

alloy commented Aug 6, 2012

@irrationalfab I don’t think it should be enabled by default. We want users to know that there are in fact warnings, because the user might find that important to know and/or might fix it and submit a patch and they can make in an informed decision.

@fabiopelosin
Copy link
Member

@alloy After I gave some thought to comment, I agree with you.

@yvbeek
Copy link

yvbeek commented Aug 17, 2012

alloy's post_install quickfix doesn't seem to work for header file warnings.
Is there a way to turn these off?

I get Multiple declarations warnings from the RestKit and MagicalRecord pods.

@fabiopelosin
Copy link
Member

I get Multiple declarations warnings from the RestKit and MagicalRecord pods.

Mhmm, what is you issue specifically?

@alloy
Copy link
Member

alloy commented Aug 20, 2012

@Zyphrax Any update on this?

I will add this feature tonight, so it would be nice to have as much info as possible :)

@yvbeek
Copy link

yvbeek commented Aug 20, 2012

@alloy

I'm a bit new to Xcode and objective-C so it might be just my noobism, but:

My project is using a few Pods: RestKit, ActiveRecord and KeychainItemWrapper.
The RestKit project has some warnings about double method declarations in some of the header files. It would be great if I could ignore just the warnings in the Pods project. I tried to disable the warnings on the Pods project manually, but since the headers are used by my project I will still get the warnings.

Probably the best solution is to try and get the maker of the piece of code to resolve the warnings.
However if you guys know a solution to ignore any warnings generated by the Pod code (both headers and implementation) that would be great. Perhaps the ability to specify compiler flags for them?

@alloy
Copy link
Member

alloy commented Aug 20, 2012

@Zyphrax Ah, I see. Unfortunately I don’t know a solution for that issue… As headers aren’t compiled directly themselves, there is no way to set compiler flags for them. Your best bet is to submit a patch to the authors with the warnings fixed.

@alloy
Copy link
Member

alloy commented Aug 20, 2012

Fixed!

@alloy alloy closed this as completed Aug 20, 2012
@yas375
Copy link
Contributor Author

yas375 commented Aug 22, 2012

Sorry guys that I promised and didn't implement this(
And thanks for this functionality!

@alloy
Copy link
Member

alloy commented Aug 22, 2012

@yas375 Enjoy! :)

fabiopelosin added a commit that referenced this issue Aug 22, 2012
* master: (21 commits)
  Release 0.13.0
  Changelog
  [UserProjectIntegrator] Don't warn about overridden build settings if silent.
  [OpenURI] Reworked support for http to https redirects.
  [Podfile#podspec] Changelog and added disabled tests.
  [Podfile] Added Podfile#podspec.
  [Changelog]
  [UserProjectIntegrator] Check if the xcconfig files is overridden.
  [Linter] Detect warning disabling compiler flags.
  [OpenURI] Support for unsafe redirects.
  [inhibit_all_warningsDon't affect the final project.
  Release 0.12.0
  [Examples] Update RKTwitter Podfile.lock
  [CHANGELOG] Add entry about namespacing subspecs in Pods.xcodeproj
  [CHANGELOG] Update for 0.12.0
  [Project] Namespace subspecs in groups.
  Document Podfile#inhibit_all_warnings!
  Add Podfile#inhibit_all_warnings! to silence warnings, but not by default. #209
  Changelog
  "[Specification] Allow to require_arc in subspecs."
  ...
@hfossli
Copy link

hfossli commented Jun 19, 2013

Coult it be possbiel to inhibit warnings on specific pods? Like it is possible with specific files in xcode? http://stackoverflow.com/questions/6921884/xcode-4-how-to-suppress-all-warning-in-specific-source-file

@hfossli
Copy link

hfossli commented Jun 19, 2013

That would be really great when working with local pods....

@yas375
Copy link
Contributor Author

yas375 commented Jun 19, 2013

@hfossli I didn't try it yet, but documentation says you can inhibit warnings per pod:

pod 'SSZipArchive', :inhibit_warnings => true

Happy coding ;)

@hfossli
Copy link

hfossli commented Jun 19, 2013

Sweet!! What about in a podspec with dependencies?

@yas375
Copy link
Contributor Author

yas375 commented Jun 19, 2013

@hfossli what do you mean? Could you please give a real example?

@hfossli
Copy link

hfossli commented Jun 19, 2013

@yas375 Ok. I'll tell you about my setup. :)

AGCore uses AGServices as a pod
AGServices has dependencies to other pods.
When in development of AGCore we are using local path to AGServices.
We want all warnings about AGServices to be revealed in AGCore, but omit any warnings from AGServices' dependencies.

A bit tricky to explain in a simple way...

@hfossli
Copy link

hfossli commented Jun 19, 2013

So basically if it is possible to write something like this in the podspec that would be sufficient.

Pod::Spec.new do |s|
  s.name = 'AGServices'
  # ...
  s.dependency      'AFNetworking', :inhibit_warnings => true
end

@yas375
Copy link
Contributor Author

yas375 commented Jun 19, 2013

@hfossli I see. Unfortunately I can't help here. Maybe someone else will answer to your question...

@supermarin
Copy link

If you inhibit warnings per pod, it's dependencies should also have inhibited warnings (unless you include one of them manually as well).

@hfossli
Copy link

hfossli commented Jun 20, 2013

@yas375 and @mneorr Well.. It's not pretty, but it works :)

# Lists all pods IVYServices uses to avoid warnings
puts 'Using a hack to avoid warnings from all the pods used directly or indirectly by AGServices'
pod 'Reachability', :inhibit_warnings => true
pod 'AFNetworking', :inhibit_warnings => true
pod 'NSLogger-CocoaLumberjack-connector', :inhibit_warnings => true
pod 'TouchDB', :inhibit_warnings => true
pod 'CouchCocoa', :inhibit_warnings => true
pod 'RestKit', :inhibit_warnings => true
pod 'BlocksKit', :inhibit_warnings => true
pod 'JSONKit', :inhibit_warnings => true
pod 'Overline-BlocksKit', :inhibit_warnings => true

pod 'AGServices', :path => '../services-ios'

I have to know every single pod AGServices is using in order for this to work.

Thanks for the tip!

@hfossli
Copy link

hfossli commented Jun 20, 2013

If I only could do the opposite? :)

@fabiopelosin
Copy link
Member

In an ideal world users of open source libraries would just fix the warnings and submit the patch to the original project, as in 99% of the cases is trivial to do. This is one of the reason why I think that the current support for this feature is more than enough.

@supermarin
Copy link

@hfossli well, we might have what you need :)

inhibit_all_warnings! # this will disable all the warnings for all pods
pod 'AGServices', :path => '../services-ios'

jzapater pushed a commit to jzapater/CocoaPods that referenced this issue Sep 17, 2013
fabiopelosin added a commit that referenced this issue Oct 25, 2014
* master: (21 commits)
  Release 0.13.0
  Changelog
  [UserProjectIntegrator] Don't warn about overridden build settings if silent.
  [OpenURI] Reworked support for http to https redirects.
  [Podfile#podspec] Changelog and added disabled tests.
  [Podfile] Added Podfile#podspec.
  [Changelog]
  [UserProjectIntegrator] Check if the xcconfig files is overridden.
  [Linter] Detect warning disabling compiler flags.
  [OpenURI] Support for unsafe redirects.
  [inhibit_all_warningsDon't affect the final project.
  Release 0.12.0
  [Examples] Update RKTwitter Podfile.lock
  [CHANGELOG] Add entry about namespacing subspecs in Pods.xcodeproj
  [CHANGELOG] Update for 0.12.0
  [Project] Namespace subspecs in groups.
  Document Podfile#inhibit_all_warnings!
  Add Podfile#inhibit_all_warnings! to silence warnings, but not by default. #209
  Changelog
  "[Specification] Allow to require_arc in subspecs."
  ...
@VladislavShchegolev
Copy link

In Podfile

post_install do |installer|
    # Pod-Framework
    installer.pods_project.targets.each do |target|
        if target.name == 'Pod-Framework'
            target.build_configurations.each do |config|
                config.build_settings['WARNING_CFLAGS'] ||= ['"-Wno-nullability-completeness"']
            end
        end
    end
    # Pod-Framework - disable nullability completeness warning for all headers
    pod_framework_umbrella_file = File.join(project_pods_root, "Target\ Support\ Files/Pod-Framework/Pod-Framework-umbrella.h")
    pod_framework_umbrella_content = File.read(pod_framework_umbrella_file)
    pod_framework_umbrella_content.prepend(
        <<~END
        #pragma GCC diagnostic push
        #pragma GCC diagnostic ignored \"-Wnullability-completeness\"\n
        END
    )
    pod_framework_umbrella_content.concat(
        <<~END
        #pragma GCC diagnostic pop
        END
    )
    File.open(pod_framework_umbrella_file, "w") { |file| file.puts pod_framework_umbrella_content }
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants