xcode 禁用所选文件的“文档注释”警告

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

Disable "Documentation Comments" warning for selected files

xcodedocumentationwarnings

提问by Guilherme

Xcode has the ability to check for Documentation Comments issues and report warnings when something is not quite right. For instance, I've added Facebook SDK to my project using CocoaPods. At some point in the file FBError.hthere's the following code:

Xcode 能够检查文档注释问题并在出现问题时报告警告。例如,我使用 CocoaPods 将 Facebook SDK 添加到我的项目中。在文件FBError.h中的某个点有以下代码:

/*!
 @typedef NS_ENUM (NSInteger, FBErrorCategory)

 @abstract Indicates the Facebook SDK classification for the error

 @discussion
 */

Note that the @discussionparameter is empty, and Xcode will generate a warning accordingly:

注意@discussion参数为空,Xcode会相应地产生警告:

Empty paragraph passed to '@discussion' command

传递给“@discussion”命令的空段落

However, Facebook SDK is not the only library I've added to my project, and the Issues tab is full of other documentation related warnings from 3rd party files, from the Pods I installed.

但是,Facebook SDK 并不是我添加到我的项目中的唯一库,并且“问题”选项卡充满了来自我安装的 Pod 的 3rd 方文件的其他文档相关警告。

I'd like to know how to suppress this kind of warning for those files.

我想知道如何抑制这些文件的这种警告。

回答by Thorsten

You can use this snippet to suppress the warnings:

您可以使用此代码段来抑制警告:

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdocumentation"

#import <YourHeader.h>

#pragma clang diagnostic pop

see this cocoapod-issue for details: https://github.com/CocoaPods/CocoaPods/issues/1481(snippet comes from there)

有关详细信息,请参阅此 cocoapod 问题:https: //github.com/CocoaPods/CocoaPods/issues/1481(片段来自那里)

回答by wj2061

I face the same issue when using cocoapods.
If you are using cocoapods, and wants to silence the warnings from pods files,you can do this:

使用 cocoapods 时我面临同样的问题。
如果您正在使用 cocoapods,并且想要使来自 pods 文件的警告静音,您可以这样做:

  1. In your target's Build Settings, select All&& Levels, then search for documentation comments.
  2. Then change your Project's documentation commentsto NO,change your target's documentation commentsto YES.
  3. Then Clean build floder(Press Command+Option+Shift+K), rebuid your target.You will silence the Document issuewarning from your pods files, and still have them for your own files.
  4. In case you want to silence your own files as well, keep your target's documentation commentsto NOwill do the trick.
  5. The result will look like this:
  1. 在目标的 中Build Settings,选择All&& Levels,然后搜索documentation comments
  2. 然后将您的项目更改documentation commentsNO,将您的目标更改documentation commentsYES
  3. 然后 Clean build floder(按 Command+Option+Shift+K),重新构建你的目标Document issue。你将从你的 pods 文件中消除警告,并且仍然为你自己的文件保留它们。
  4. 如果您还想使自己的文件静音,保持目标文件documentation comments即可NO
  5. 结果将如下所示:

enter image description here

在此处输入图片说明

回答by Y.Bonafons

What about ignoring warning coming from library added by cocoapods?

忽略来自 cocoapods 添加的库的警告怎么样?

In your podfile, add

在您的 podfile 中,添加

inhibit_all_warnings!

to remove all warning

删除所有警告

Or

或者

pod 'Facebook-iOS-SDK', :inhibit_warnings => true

to remove warnings from specific library.

从特定库中删除警告。