使 Xcode 忽略 3rd 方项目中的 LLVM 构建警告

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7535291/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 22:01:01  来源:igfitidea点击:

Make Xcode ignore LLVM build warnings in 3rd party project

xcodellvm

提问by Christian Schlensker

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.

我的 Xcode 工作区中有一个第三方项目(它是我的主项目的依赖项),我希望 Xcode 忽略来自该第三方项目的所有构建警告。

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.

我最好忽略项目中 Vendor/* 组的所有构建警告,因为这是我放置所有第三方代码的地方。

Possible?

可能的?

采纳答案by Macmade

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.

这样,您就可以在应用程序中使用第三方代码,同时为第三方代码设置不同的编译器设置。

回答by soryu2

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/

可以基于每个文件,请参阅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.

总结:使用“构建阶段”选项卡上的编译器标志。

回答by Hari Karam Singh

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 Flagscolumn. Add -wand hit return:

转到Build Phases> Compile Sources。(可选)过滤列表。选择要排除的那些,然后双击Compiler Flags列下的空白区域。添加-w并按回车:

Adding compiler flag to Build Phase

将编译器标志添加到构建阶段

回答by justin

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 -wor GCC_WARN_INHIBIT_ALL_WARNINGS = YESfor the third party target which you link to or bundle.

如果您还想禁用它生成的构建警告,那么您可以使用-wGCC_WARN_INHIBIT_ALL_WARNINGS = YES链接到或捆绑的第三方目标。

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

理想情况下,如果供应商关闭,您将向供应商提交报告。如果它是开放的,那么也许你应该自己修补它。