How do I disable NSLog?

前端 未结 15 2129
陌清茗
陌清茗 2020-12-05 07:46

I\'d like to do the following in Xcode:

Find all NSLog commands without comments, and replace it with //NSLog...

In other words, I want to comment all NSLog

15条回答
  •  南笙
    南笙 (楼主)
    2020-12-05 08:24

    How to disable NSLog in Xcode for Production stage

    Add #define NSLog in appName-Prefix.pch file in Supporting Files Folder of your project and result file code look like...

    // Prefix header for all source files of the 'NSLog' target in the 'NSLog' project
    //
    
    #import 
    
    #ifndef __IPHONE_4_0
    #warning "This project uses features only available in iOS SDK 4.0 and later."
    #endif
    
    #ifdef __OBJC__
        #import 
        #import 
    #endif
    
    //Add this to disable NSLog
    #define NSLog //
    

提交回复
热议问题