25

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.

Guilherme
  • 7,839
  • 9
  • 56
  • 99
  • Depending on how you have your project setup and which Project(s), Target(s), and Dependencies have the Documentation Comments (CLANG_WARN_DOCUMENTATION_COMMENTS) set to Yes will determine which avenues are open for suppressing things. Could you post a sanitized version of your podspec and list project-level and/or target-level(s) where you've set 'Documentation Comments' to YES? – Bryan Musial Jan 09 '15 at 19:10
  • Try this with XCode 8 [https://stackoverflow.com/questions/42991455/silencing-documentation-issue-warnings-in-xcode/43234526#43234526](https://stackoverflow.com/questions/42991455/silencing-documentation-issue-warnings-in-xcode/43234526#43234526) – mohit_IBS Jun 16 '17 at 06:16

3 Answers3

41

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)

gnasher729
  • 51,477
  • 5
  • 75
  • 98
Thorsten
  • 3,102
  • 14
  • 14
  • Thanks! It's not great having to do this wherever the headers are imported, but it's better than disabling the warnings for the entire target. – Jim Jan 13 '15 at 11:35
  • it's less typing if you create a macro for the pragma settings, i.e.: #define DISABLE_DWARN \ _Pragma("clang diagnostic push") \ _Pragma("clang diagnostic warning \"-Wdeprecated-declarations\"") but I don't think you can use #import in a macro. – Thorsten Jan 13 '15 at 18:43
  • 2
    I get a warning unless the last line is `#pragma clang diagnostic pop` – Glen T Dec 12 '15 at 02:44
  • 1
    This is fantastic. I've been working with the aws-sdk-cpp library in Xcode, and it generates hundreds of "Documentation Issue" warnings. These pragmas solve that problem. – Jon Buys Sep 13 '17 at 12:23
18

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:

enter image description here

wj2061
  • 6,778
  • 3
  • 36
  • 62
  • documentation warnings still appear after following the steps in your question, even after clean rebuilt – Raptor Jun 26 '17 at 09:48
  • @Raptor check both targets and project `Documentation Comments`, select 'Levels' at the top left corner, to see what the `Resolved` result is, and what override it . – wj2061 Jun 26 '17 at 10:11
  • I had to turn documentation comments off when selecting my Pods sub project to get the warnings to disappear. – sargturner Apr 25 '18 at 18:00
8

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.

Y.Bonafons
  • 2,329
  • 13
  • 20
  • Thank you. This works for me.`# Uncomment the next line to define a global platform for your project platform :ios, '10.3' inhibit_all_warnings! pod 'RealmSwift'` – Owen Zhao Apr 08 '17 at 06:16