Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

JimBobBennett

macrumors member
Original poster
May 4, 2009
65
0
I've got some code in my app that is for debugging purposes only, including resource files. Can anyone point me in the direction of some information about how to define debug only symbols so I can compile with and without my debug code, and how to specify that a resource only appiles to one configuration?

I've tried googling it, but getting nowhere...

Many thanks in advance!
 
Define your own copy-file build phase for those resources and only add it to the build-type you want those resources in?

I've never head of the copy file build phase before - bit of an xcode newbie.
I'll have a google and see what I can do. Thanks for all your help - sometimes us newbies just need a slight nudge in the right direction.
 
my solution

throw this code into your AppName_Prefix.pch file, and don't worry about setting a preprocessor macros in the target build (as some of those tutorials online suggest).

Code:
[COLOR="Green"]//Toggle DebugLog() Visibility[/COLOR]
#define ShowDebugLogs 0

[COLOR="green"]//DebugLog() Visibility[/COLOR]
#if ShowDebugLogs
#define DebugLog(…) NSLog(__VA_ARGS__)
#else
#define DebugLog(…)
#endif

[COLOR="green"]//ReleaseLog() Visibility[/COLOR]
#define ReleaseLog(…) NSLog(__VA_ARGS__)

in the example above, ShowDebugLogs is set to off (that's what the zero means). change the zero to one to turn it on - obviously. so anywhere in my code that has DebugLog(@"debug log example");, will not output. However, anywhere in my code that has ReleaseLog(@"release log example"); will always output, just like a regular NSLog() call.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.