从框架中禁用 Xcode 中的警告

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7997636/
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-09 04:09:31  来源:igfitidea点击:

Disable warnings in Xcode from frameworks

xcodexcode4.2compiler-warningssuppress-warnings

提问by Micah Hainline

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.

我已经将three20项目导入到我的项目中,当我用iOS 5升级到Xcode 4.2时,项目中出现了一堆警告。

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?

我不在乎它们,但它们会产生很多噪音,现在很容易错过我项目中的任何真正警告。有没有办法禁用这些特定库的警告?

回答by iHunter

  1. If your third-party libraries are added as a separate target, you can check Inhibit all warningsfor 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 -wcompiler flag for individual sources to mute all warnings in them. You have to go to Build phasesmenu of your target configuration and set this flag for each source file in Compile Sourcessection by double clicking on each file end entering -wflag. enter image description here

  1. 如果您的第三方库作为单独的目标添加,您可以检查Inhibit all warnings该特定目标以关闭所有警告。

  2. 如果您的库作为普通源文件添加到当前目标,您可以-w为各个源设置编译器标志以静音其中的所有警告。您必须转到Build phases目标配置的菜单,并Compile Sources通过双击每个文件结尾输入-w标志为部分中的每个源文件设置此标志。 在此处输入图片说明

回答by Alaa Eddine Cherbib

If you are using pods, you can add this to your podfile to prevent warnings logging:

如果您正在使用 pod,您可以将其添加到您的 podfile 中以防止记录警告:

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

回答by Vladimir Grigorov

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 flag by warning message at ClangWarnings.com

将警告标志放在上面的第二行。您可以通过ClangWarnings.com 上的警告消息查找警告标志