Micah Hainline
Micah Hainline

Reputation: 14417

Disable warnings in Xcode from frameworks

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?

Upvotes: 75

Views: 32959

Answers (5)

Bryan
Bryan

Reputation: 5700

If you're using a third-party static library (libSomething.a) and importing the headers from that library, this works to silence all warnings as of Xcode 15:

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Weverything"
#include "someHeader.h"
#include "someOtherHeader.h"
#pragma clang diagnostic pop

(I saw some older comments that -Weverything didn't work on older Xcode versions, but it does on 15 at least.) This is much more convenient than looking up individual warning flags in Clang's list of 19,457 flags.

Upvotes: 0

Vlad Grigorov
Vlad Grigorov

Reputation: 11378

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

Upvotes: 8

NSExceptional
NSExceptional

Reputation: 1390

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

Upvotes: 0

Alaa Eddine Cherbib
Alaa Eddine Cherbib

Reputation: 1514

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

Upvotes: 21

iHunter
iHunter

Reputation: 6205

  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

Upvotes: 162

Related Questions