Disable warnings in Xcode from frameworks

Xcodexcode4.2Compiler WarningsSuppress Warnings

Xcode Problem Overview


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?

Xcode Solutions


Solution 1 - Xcode

  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. enter image description here

Solution 2 - Xcode

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

Solution 3 - Xcode

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 flags here: https://clang.llvm.org/docs/DiagnosticsReference.html

Solution 4 - Xcode

If the warnings are coming from a framework (for me it was Rollbar) that was added with Carthage:

  1. Add a new framework target (i.e. RollbarWrapper) to your project and embed it within your application target

enter image description here

  1. Drag the built framework from Carthage/Build/<platform> into Xcode, adding it to the dummy/wrapper framework you just created (RollbarWrapper)

enter image description here

  1. Make sure that the framework (Rollbar) is added to the dummy/wrapper framework (RollbarWrapper) target's Frameworks and Libraries section and is set to Do Not Embed

enter image description here

  1. Go to the Build Settings for the dummy/wrapper framework (RollbarWrapper) and set "Inhibit All Warnings" to Yes

  2. Next, add the framework (Rollbar) to your application target's Frameworks, Libraries, & Embedded Content section and set to Do Not Embed

enter image description here

  1. Finally, for the application target, do the normal Carthage setup (i.e. create a new Run Script Phase to execute the copy-frameworks script to copy the Rollbar framework)

enter image description here

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMicah HainlineView Question on Stackoverflow
Solution 1 - XcodeiHunterView Answer on Stackoverflow
Solution 2 - XcodeAlaa Eddine CherbibView Answer on Stackoverflow
Solution 3 - XcodeVladimir GrigorovView Answer on Stackoverflow
Solution 4 - XcodeNSExceptionalView Answer on Stackoverflow