Disable warnings in Xcode from frameworks

2019-01-12 19:03发布

问题:

I have imported the three20 project into my project, and when I upgraded to Xcode 4.2 with iOS 5, a bunch of warnings appeared in the project.

I don't care about them, but they make a lot of noise, and it's easy to miss any real warnings in my project now. Is there a way to disable warnings for those specific libraries?

回答1:

  1. If your third-party libraries are added as a separate target, you can check Inhibit all warnings for that specific target to turn all warnings off.

  2. If your library is added as plain source files to your current target, you can set -w compiler flag for individual sources to mute all warnings in them. You have to go to Build phases menu of your target configuration and set this flag for each source file in Compile Sources section by double clicking on each file end entering -w flag.



回答2:

If you are using pods, you can add this to your podfile to prevent warnings logging:

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


回答3:

If the warnings come from the included library or framework header files, you can wrap that include statements like this:

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wnullability-completeness"
#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <FBSDKShareKit/FBSDKShareKit.h>
#pragma clang diagnostic pop

Put your warning flag on the second line above. You can lookup a warning flag by warning message at ClangWarnings.com