Search code examples
xcodecompiler-warningssuppress-warnings

How to turn off specific errors in Xcode?


Is there a way to selectively turn off specific errors in Xcode?

Specifically, I want to turn off the following errors

Use of undeclared identifier..

No visible @interface for ... declares the selector

I want this to fail during runtime for certain targets instead at compile time.


Solution

  • As @CodaFi notes, you can't reasonably suppress "use of undeclared identifier." The compiler can't generate code if it doesn't know what the symbol represents.

    The normal way to deal with "No visible @interface declares" warning is to just declare the methods. You can do this in an NSObject category like this:

    @interface NSObject (AdditionalMethods)
    - (void)someUnknownSelector;
    @end
    

    This is how we used to create protocols back before you could have @optional members. There's still quite a lot of it scattered around Cocoa.

    While it's possible to suppress the warning, that is not recommended since it's confuse ARC. It's better to tell the compiler that you know what you're doing, and give it some hints on what that might be.