Tuesday, September 28, 2010

XCode - turn off logging for Release

Welcome to my first tip for iPhone developers.

If you have logging statements in your project for testing and debugging, you’ll want a way to turn them off for released code.

I have seen many complex solutions requiring custom macros and preprocessor parameters, most of them overkill IMHO.

The simplest thing to do that I have found so far is to use this technique.
Place the code-snippet in your project’s *_Prefix.pch file, continue to use the standard NSLog() macro.

NSLog statements will be automatically left out of projects compiled for release.

I hope this helps.

No comments: