Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to suppress header file warnings from an Xcode project

When I build UnzipKit in Xcode 7 beta 4, I'm getting a compiler warning in MiniZip's ioapi.h file. For example:

.../ioapi.h:22:9: warning: macro name is a reserved identifier [-Wreserved-id-macro]
#define _ZLIBIOAPI64_H

ioapi.c has many of its own warnings, so I compile it with -Wno-everything like so:

Compile Sources build phase

However, there is no "Compiler Flags" setting available for the headers:

Headers build phase

How can I silence the warning without modifying the source file? I'd rather not modify it, as it's an external dependency. I also don't want to turn it on for the whole project, because it's a useful warning for my own code.

like image 206
Dov Avatar asked Jul 31 '15 21:07

Dov


People also ask

How do I silence warnings in Xcode?

If you want to disable all warnings, you can pass the -suppress-warnings flag (or turn on "Suppress Warnings" under "Swift Compiler - Warning Policies" in Xcode build settings).

How do I open a header file in Xcode?

File→Open Quickly: Command-D Pops up a panel where you can type a file name. This is most frequently used for opening header files from the Cocoa frameworks. You can type in a name without an extension and Xcode will first try to find an implementation file and if it can't find one will look for an interface file.


1 Answers

I found my answer using this one: https://stackoverflow.com/a/7535436/2148757

I imagine your code would look like this:

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Weverything"
#import "ioapi.h" //Hide a warning in this header because we don't want to change our dependencies
#pragma clang diagnostic pop

Edit: I did not need to import the header file in our project where this worked, but I imported it anyway into the PrefixHeader.pch file to remove the warning.

like image 143
Sashah Avatar answered Dec 22 '22 00:12

Sashah