Disable warnings in Xcode from frameworks
Xcodexcode4.2Compiler WarningsSuppress WarningsXcode 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
-
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. -
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 toBuild phases
menu of your target configuration and set this flag for each source file inCompile Sources
section by double clicking on each file end entering-w
flag.
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:
- Add a new framework target (i.e. RollbarWrapper) to your project and embed it within your application target
- Drag the built framework from
Carthage/Build/<platform>
into Xcode, adding it to the dummy/wrapper framework you just created (RollbarWrapper)
- 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
-
Go to the Build Settings for the dummy/wrapper framework (RollbarWrapper) and set "Inhibit All Warnings" to Yes
-
Next, add the framework (Rollbar) to your application target's Frameworks, Libraries, & Embedded Content section and set to Do Not Embed
- 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)