Update:
More info on this here:
Is it true that one should not use NSLog() on production code?
~~~~~~~~~~~~~~~~~~~~~~~~
Situation
I have some pretty beafy NSLog calls that I use for debugging the more complex parts of my application. However, I just recently learned that these affect runtime performance!
Goal
I would like to remove my NSLog calls during any run where I am not actually performing Product > Run (aka command-R) from within Xcode – ESPECIALLY in situations when this thing is deployed on the App Store, but also when I am running the app when disconnected from Xcode (i.e. just tapping the icon while walking down the street).
Proposed Solution?
Assuming I’ve created a Preprocessor Macro of VIEW_DEBUG, would the following implementation effectively remove NSLog calls from executing in the cases I’ve described above?
<bunch of code>
#ifdef VIEW_DEBUG
NSLog(@"really complex logs entries");
#endif
<even more code>
This is a difficult one for me to ‘test’, so I figured I would appeal to more experienced minds. 🙂
Xcode Settings (for reference)

A common solution is to place the following code in your Prefix file (or you may create a dedicated class and
#includeit as needed):Xcode already defines DEBUG for you when performing a debug build (as shown in your screenshot). VA_ARGS is a way of creating variadic macros that was introduced in C99. the
do/whileensures that DebugLoghas the same net syntactic effect even when it doesn’t do anything — don’t worry about the pointless loop, the optimiser will remove it for you.
Then you can just use
DebugLogexactly as you’d useNSLog. This will do exactly what you propose withVIEW_DEBUGbut without you having to copy and paste the#ifdefcondition a thousand times over.