从框架禁用 Xcode 中的警告
我已经将 Three20 项目导入到我的项目中,当我使用 iOS 5 升级到 Xcode 4.2 时,项目中出现了一堆警告。
我不关心它们,但它们会产生很大的噪音,而且现在很容易错过我的项目中的任何真正的警告。有没有办法禁用这些特定库的警告?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
如果您的第三方库作为单独的目标添加,您可以选中该特定目标的
禁止所有警告
以关闭所有警告。如果您的库作为纯源文件添加到当前目标,您可以为各个源设置
-w
编译器标志以消除其中的所有警告。您必须转到目标配置的Build Phases
菜单,并通过双击每个文件末尾输入- 为
标志。Compile Sources
部分中的每个源文件设置此标志wIf 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.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 toBuild phases
menu of your target configuration and set this flag for each source file inCompile Sources
section by double clicking on each file end entering-w
flag.如果您使用 pod,您可以将其添加到 podfile 以防止记录警告:
If you are using pods, you can add this to your podfile to prevent warnings logging:
如果警告来自包含的库或框架头文件,您可以像这样包装包含语句:
将警告标志放在上面的第二行。您可以在此处查找警告标志: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:
Put your warning flag on the second line above. You can lookup a warning flags here: https://clang.llvm.org/docs/DiagnosticsReference.html
如果警告来自使用 Carthage 添加的框架(对我来说是 Rollbar):
Carthage/Build/
导入 Xcode,将其添加到您刚刚创建的虚拟/包装框架 (RollbarWrapper)转至为虚拟/包装框架 (RollbarWrapper) 构建设置并将“禁止所有警告”设置为是
下一步,将框架 (Rollbar) 添加到应用程序目标的框架、库和应用程序中;嵌入内容部分并设置为“不嵌入”
copy-frameworks
脚本来复制 Rollbar 框架)If the warnings are coming from a framework (for me it was Rollbar) that was added with Carthage:
Carthage/Build/<platform>
into Xcode, adding it to the dummy/wrapper framework you just created (RollbarWrapper)Go to the Build Settings for the dummy/wrapper framework (RollbarWrapper) and set "Inhibit All Warnings" to Yes
Next, add the framework (Rollbar) to your application target's Frameworks, Libraries, & Embedded Content section and set to Do Not Embed
copy-frameworks
script to copy the Rollbar framework)如果您使用第三方静态库 (
libSomething.a
) 并从该库导入标头,这可以消除 Xcode 15 中的所有警告:(我看到一些较旧的评论 < 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:(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.