How do I disable NSLog?

前端 未结 15 2097
陌清茗
陌清茗 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:38

    You can use following Preprocessor Directives, it will not go with release mode. So you don't have to commenting NSLog().

    #ifdef DEBUG
        NSLog(@"YOUR MESSAGE HERE!");
    #endif
    
    0 讨论(0)
  • 2020-12-05 08:39

    wait there is far more simple method. Just add the following lines when you dont need NSLOG to your constants file

    #define NSLog                       //
    

    and comment it when you need it.

    EDIT: In latest Xcode, you get error on above statement. So I figured out the best way is

    #define NSLog(...) 
    
    0 讨论(0)
  • 2020-12-05 08:40

    right click on NSLog statement in xcode and select "find in project" as text.you would be prompted to a new window where you can follow the guidance given by Mihai Fratu.

    TNQ

    0 讨论(0)
提交回复
热议问题