Search code examples
iosobjective-cxcodeclangnslog

Treat using NSLog as a build error


I want to treat any NSLog in my code as an error. The line should be a compile time error in Xcode. Just like how usage of release in an ARC enabled project is treated as an error.


Solution

  • Try this,

    #define NSLog_UNAVAILABLE __attribute__((unavailable("NSLog is treated as Error.")))
    FOUNDATION_EXPORT void NSLog(NSString *format, ...) NS_FORMAT_FUNCTION(1,2) NSLog_UNAVAILABLE;