Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSLog and deployment builds



On 1/31/05 6:25 AM, "Larry Fransson" <email@hidden> wrote:

> On Jan 30, 2005, at 22:30, James J. Merkel wrote:
>> 
>> Suggestion  to the xcode team -- why not have an option in the
>> Deployment build style to not compile NSLog statements?
>> The statements would still be there in Development builds -- so I
>> wouldn't need to un-comment them again if I wanted to use them again.
> 
> There are occasions when you want to leave some NSLog()s in the code -
> it can be helpful for troubleshooting when something goes wrong.  If
> you want to turn them off for deployment builds, use an #ifdef and
> define a flag in your development builds like this:
> 
> #ifdef DEBUG
> NSLog(@"foo");
> #endif
> 
> and then put -DDEBUG in "other C flags" for your development build
> style.

I put the following in my <AppName>_Prefix.pch file:

#define ZNLog if([[NSUserDefaults standardUserDefaults]
boolForKey:@"WriteDebugInfo"])NSLog

This is a one line macro (remove the break if it wrapped).  I have
statements like the following in my code

ZNLog(@"The value of foo is: %@", foo);

The Preferences window for the app has a checkbox to enable or disable debug
output to the console.  If the users (or me) are having problems, enabling
the option will activate all the ZNLogs in the app.  With the option
disabled, the ZNLogs do not write to the console.

-- 
Julian Vrieslander <email@hidden>


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/xcode-users/email@hidden

This email sent to email@hidden

References: 
 >Re: NSLog and deployment builds (From: Larry Fransson <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.