Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make Xcode ignore LLVM build warnings in 3rd party project

Tags:

xcode

llvm

I have a third party project in my Xcode workspace (it's a dependency for my main project) and I want Xcode to ignore all build warnings from that third party project.

Preferably I'd like to ignore all build warnings for the Vendor/* group in my project since that's where I put all my third party code.

Possible?

like image 249
Christian Schlensker Avatar asked Sep 23 '11 21:09

Christian Schlensker


4 Answers

Yes, it's possible, but only if you compile the third-party files in a separate target. This way, you can set different compiler flags.

Let's say your main target is an application. You defined your build settings, as well as the compiler warning flags.

Now you want to use some third-party sources. You import them into your project, but they generate warning. You could of course change your main target's settings, but I'm pretty sure you want to keep your own settings.

Simply create an additional target in your project, which is a static library. Removes the third-party files from your main target, and add them to the library.

In your main target's build phases, link your application with the static library.

This way, you'll be able to use the third-party code in your application, while having different compiler settings for third-party code.

like image 181
Macmade Avatar answered Oct 12 '22 22:10

Macmade


It is possible on a per file basis, see the blog entry at http://blog.bluelightninglabs.com/2011/12/suppressing-xcode-warnings-on-a-per-file-basis/

To summarize: Use the compiler flags on the “Build phases” tab.

like image 21
soryu2 Avatar answered Oct 13 '22 00:10

soryu2


Go to Build Phases > Compile Sources. Optionally filter the list. Select the ones you want to exclude and then double click in the blank area under the Compiler Flags column. Add -w and hit return:

Adding compiler flag to Build Phase

like image 41
Hari Honor Avatar answered Oct 12 '22 22:10

Hari Honor


if you are worried only about warning via inclusion, then you can wrap your include statements in this:

#pragma clang diagnostic push
 // in reality, you will likely need to disable *more* than Wmultichar
#pragma clang diagnostic ignored "-Wmultichar"
#include <TheirLibrary/include.h>
#pragma clang diagnostic pop

if you also want to disable the build warnings it generates, then you can use -w or GCC_WARN_INHIBIT_ALL_WARNINGS = YES for the third party target which you link to or bundle.

ideally, you will file reports with the vendor if it is closed. if it is open, then maybe you should just patch it yourself.

like image 34
justin Avatar answered Oct 13 '22 00:10

justin