31

For a limited time I want to suppress these kind of warnings the compiler is showing me in Xcode 7.3.1:

<File>: Pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified)

I have added this compiler flag to all classes under My Target/Build Phases/Compile Sources: -Wnullability-completeness

But it's not working - the warnings are still shown. How can I get rid of the warnings?

Cœur
  • 37,241
  • 25
  • 195
  • 267
electronix384128
  • 6,625
  • 11
  • 45
  • 67

4 Answers4

42

To disable those warnings, you want: -Wno-nullability-completeness. Note the no-; the flag you're using enables those warnings.

Carl Norum
  • 219,201
  • 40
  • 422
  • 469
  • 5
    Cool, that worked on the .m files. Any idea how to disable it for the .h files? – electronix384128 Jun 07 '16 at 23:57
  • 7
    I added this in XCode 9 (or 8) by adding it to `Build Settings` -> `Apple LLVM 9.0 - Custom compiler flags` -> `Other Warning Flags`. You can just search for `Other Warning Flags` – xaphod Sep 15 '17 at 20:08
  • 4
    In Xcode 10, this was moved to Apple Clang - Custom Compiler Flags > Other Warning Flags – Dávid Pásztor Apr 17 '19 at 13:26
9

Note that in Xcode 11 it is now -Wno-nonnull

It should be set in "Other Warning Flags" in the "Apple Clang - Custom Compiler Flags" section of your target.

You could also avoid these warnings and setting the above altogether by removing these flags Xcode automatically adds to new header files in Objective-C:

NS_ASSUME_NONNULL_BEGIN
NS_ASSUME_NONNULL_END
RunLoop
  • 20,288
  • 21
  • 96
  • 151
8

Settings for Xcode 11.5 when using project with mixed sources, ObjC and Swift:

WARNING_CFLAGS = $(inherited) -Wno-nullability-completeness
OTHER_SWIFT_FLAGS = $(inherited) -Xcc -Wno-nullability-completeness
Vlad
  • 6,402
  • 1
  • 60
  • 74
5

In Xcode 11.3, these started appearing out of nowhere in my pure Swift project on the Github ci. That was because I am importing the AWS Objective-C SDK.

Confoundingly, this would only occur on the first build, probably creating the module map for the framework. Hence it was only a problem on ci because of the clean builds.

Fixed it by adding this to the Swift compiler options (search for OTHER_SWIFT_FLAGS in your build settings):

-Xcc -Wno-nullability-completeness
Steven Kramer
  • 8,473
  • 2
  • 37
  • 43