Remove NSLog from releases

Possible duplicate:
Is it true that NS64 () cannot be used for production code?
Do I need to disable NSLog before releasing the application?

I need to remove all the NSLOGs that are present in my project during the release build. I tried using the code below, but still access the assembly by phone, but NSLOG appears on the console.

#ifdef DEBUG #define debug_NSLog(format, ...) NSLog(format, ## __VA_ARGS__) #else #define debug_NSLog(format, ...) #endif 
+2
ios objective-c xcode
source share
3 answers

To simply remove NSLogs:

 #define NSLog(s,...) 

A #define without the specified replacement will not replace anything by removing everything that matches this #define . This works with a simple token definition and with a-like function as above.

+12
source share

Use the following code

 #ifdef DEBUGGING # define DBLog(fmt,...) NSLog(@"%@",[NSString stringWithFormat:(fmt), ##__VA_ARGS__]); #else # define DBLog(...) #endif 

Make sure the compiler flags are set correctly.

Also, when you checked the console, did you check if you use release mode?

+4
source share

Use this

 #if TARGET_IPHONE_SIMULATOR #define NSLog(fmt,...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__); #else #define NSLog(...) #endif 

This will print NSLog if you run it on a simulator.

+1
source share

All Articles