Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

excluding NSLog's from release version of iPhone app

Could somebody go over how to exempt NSLog's from a release build of an app? Also, does it matter if comments are left in a release version? Thanks!

like image 708
Apollo Avatar asked Jan 17 '23 23:01

Apollo


2 Answers

Use a macro like DLog to wrap NSLog, and turn it off in Release builds.

#ifdef DEBUG
#    define DLog(...) NSLog(__VA_ARGS__)
#else
#    define DLog(...) /* */
#endif

Comments absolutely don't matter. They are only in your source code, not the compiled output. You don't submit your source code to Apple, only the built copy of your app.

like image 108
Kurt Revis Avatar answered Jan 28 '23 08:01

Kurt Revis


What I do to exclude NSLogs is to add this to the prefix file:

#define NSLog(...)

That way, when compiled, all NSLogs will be replaced with nothing, it will be like an empty line.

As for the comments, they never make it into the binary at all, those are ONLY for whoever can see the source code.

like image 25
EmilioPelaez Avatar answered Jan 28 '23 08:01

EmilioPelaez