How to prevent hundreds of NSLog statements from executing in release version.?

I have hundreds of NSLog statelements in my project which I would like to see not executing in the release version. Long time back I read that a way to do it is to define a macros specifically for the debug mode. I don't remember it any longer. Can someone tell me whats the best way to avoid hundreds of lines of code, useless in the release version?


Neerav

Do a gang find/replace via Xcode and comment them out.

I use this macro in my .pch file


#ifdef DEBUG
#define DLog( s, ... ) NSLog( @"<%p %@:(%d)> %@", self, [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__, [NSString stringWithFormat:(s), ##__VA_ARGS__] )
#else
#define DLog( s, ... )
#endif


That's for Objective-C of course. No idea where I got it from.

I came accross this on quora. But wasnt able to understand how it works. Can u explain?

Instead of writing "NSLog(some stuff)" in your code, you write "DLog(some stuff)". Same syntax. Then at compile time, the preprocessor either replaces that with a nicely formatted NSLog() call, or omits the whole thing, depending on whether the DEBUG flag is set. By default I believe it is not set for release builds. You can control it using build schemes.


Are you using Swift, or Objective-C? This is obviously an Objective-C solution.

“at compile time, the preprocessor either replaces that with a nicely formatted NSLog() call, or omits the whole thing, depending on whether the DEBUG flag is set. By default I believe it is not set for release builds” I read the same on quora. Is it possible to. Not have to replace hundreds of these NSLogs with Dlog?

How to prevent hundreds of NSLog statements from executing in release version.?
 
 
Q