View Full Version : #ifdef DEBUG or similar
JimBobBennett
Jun 2, 2009, 05:24 AM
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!
robbieduncan
Jun 2, 2009, 05:44 AM
You might find this helpful (http://www.karlkraft.com/index.php/2009/03/23/114/)
JimBobBennett
Jun 2, 2009, 05:59 AM
You might find this helpful (http://www.karlkraft.com/index.php/2009/03/23/114/)
Thanks - that sorts out how to define the preprocessor macros.
Any ideas about resources only existing in one build?
robbieduncan
Jun 2, 2009, 06:00 AM
Thanks - that sorts out how to define the preprocessor macros.
Any ideas about resources only existing in one build?
Define your own copy-file build phase for those resources and only add it to the build-type you want those resources in?
JimBobBennett
Jun 2, 2009, 06:07 AM
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.
robbieduncan
Jun 2, 2009, 06:10 AM
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.
It's all in the XCode Documentation (http://developer.apple.com/DOCUMENTATION/DeveloperTools/Conceptual/XcodeBuildSystem/200-Build_Phases/bs_build_phases.html)...
Darkroom
Jan 28, 2010, 01:24 PM
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).
//Toggle DebugLog() Visibility
#define ShowDebugLogs 0
//DebugLog() Visibility
#if ShowDebugLogs
#define DebugLog(…) NSLog(__VA_ARGS__)
#else
#define DebugLog(…)
#endif
//ReleaseLog() Visibility
#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.
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.