从框架禁用 Xcode 中的警告

发布于 2024-12-13 15:44:57 字数 136 浏览 0 评论 0 原文

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

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

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

厌倦 2024-12-20 15:44:57
  1. 如果您的第三方库作为单独的目标添加,您可以选中该特定目标的禁止所有警告以关闭所有警告。

  2. 如果您的库作为纯源文件添加到当前目标,您可以为各个源设置 -w 编译器标志以消除其中的所有警告。您必须转到目标配置的 Build Phases 菜单,并通过双击每个文件末尾输入 - 为 Compile Sources 部分中的每个源文件设置此标志w 标志。
    在此处输入图像描述

  1. 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.

  2. 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 to Build phases menu of your target configuration and set this flag for each source file in Compile Sources section by double clicking on each file end entering -w flag.
    enter image description here

你与昨日 2024-12-20 15:44:57

如果您使用 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

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
美人骨 2024-12-20 15:44:57

如果警告来自包含的库或框架头文件,您可以像这样包装包含语句:

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wnullability-completeness"
#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <FBSDKShareKit/FBSDKShareKit.h>
#pragma clang diagnostic pop

将警告标志放在上面的第二行。您可以在此处查找警告标志:https://clang.llvm.org/docs/DiagnosticsReference。 html

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

花伊自在美 2024-12-20 15:44:57

如果警告来自使用 Carthage 添加的框架(对我来说是 Rollbar):

  1. 将新的框架目标(即 RollbarWrapper)添加到您的项目中并将其嵌入到您的应用程序目标中

在此处输入图像描述

  1. 拖动将构建的框架从 Carthage/Build/ 导入 Xcode,将其添加到您刚刚创建的虚拟/包装框架 (RollbarWrapper)

在此处输入图像描述

  1. 确保框架 (Rollbar) 已添加到虚拟/包装框架 (RollbarWrapper) 目标的框架和库部分,并设置为“不嵌入”

在此处输入图像描述

  1. 转至为虚拟/包装框架 (RollbarWrapper) 构建设置并将“禁止所有警告”设置为

  2. 下一步,将框架 (Rollbar) 添加到应用程序目标的框架、库和应用程序中;嵌入内容部分并设置为“不嵌入”

在此处输入图像描述

  1. 最后,对于应用程序目标,执行 正常 Carthage 设置(即创建一个新的运行脚本阶段来执行 copy-frameworks 脚本来复制 Rollbar 框架)

输入图像描述这里

If the warnings are coming from a framework (for me it was Rollbar) that was added with Carthage:

  1. Add a new framework target (i.e. RollbarWrapper) to your project and embed it within your application target

enter image description here

  1. Drag the built framework from Carthage/Build/<platform> into Xcode, adding it to the dummy/wrapper framework you just created (RollbarWrapper)

enter image description here

  1. 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

enter image description here

  1. Go to the Build Settings for the dummy/wrapper framework (RollbarWrapper) and set "Inhibit All Warnings" to Yes

  2. Next, add the framework (Rollbar) to your application target's Frameworks, Libraries, & Embedded Content section and set to Do Not Embed

enter image description here

  1. 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)

enter image description here

玉环 2024-12-20 15:44:57

如果您使用第三方静态库 (libSomething.a) 并从该库导入标头,这可以消除 Xcode 15 中的所有警告:(

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Weverything"
#include "someHeader.h"
#include "someOtherHeader.h"
#pragma clang diagnostic pop

我看到一些较旧的评论 < code>-Weverything 在较旧的 Xcode 版本上不起作用,但至少在 15 版本上起作用。)这比在 Clang 的 19,457 个标志列表中查找单个警告标志要方便得多。

If you're using a third-party static library (libSomething.a) and importing the headers from that library, this works to silence all warnings as of Xcode 15:

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Weverything"
#include "someHeader.h"
#include "someOtherHeader.h"
#pragma clang diagnostic pop

(I saw some older comments that -Weverything didn't work on older Xcode versions, but it does on 15 at least.) This is much more convenient than looking up individual warning flags in Clang's list of 19,457 flags.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文