Disable “Documentation Comments” warning for selected files

一笑奈何 提交于 2019-12-20 09:22:26

问题


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.h there's the following code:

/*!
 @typedef NS_ENUM (NSInteger, FBErrorCategory)

 @abstract Indicates the Facebook SDK classification for the error

 @discussion
 */

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

Empty paragraph passed to '@discussion' command

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.

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


回答1:


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)




回答2:


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:

  1. In your target's Build Settings, select All && Levels, then search for documentation comments.
  2. Then change your Project's documentation comments to NO,change your target's documentation comments to YES.
  3. Then Clean build floder(Press Command+Option+Shift+K), rebuid your target.You will silence the Document issue warning 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 comments to NO will do the trick.
  5. The result will look like this:




回答3:


What about ignoring warning coming from library added by cocoapods?

In your podfile, add

inhibit_all_warnings!

to remove all warning

Or

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

to remove warnings from specific library.



来源:https://stackoverflow.com/questions/24453188/disable-documentation-comments-warning-for-selected-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!