8

I have an Xcode project which has lots of NSLog statementS.

I have to submit my app to get approval from Apple, and I would like to remove all NSLog statementS which I had used for debugging.

I want to remove only NSLog statements.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131

3 Answers3

13

In Xcode, you can use Find and Replace and provide a regular expression something like:

NSLog.*;
Ankit Bansal
  • 4,962
  • 1
  • 23
  • 40
8

Put this in your prefix header......

   #ifndef __OPTIMIZE__

    #    define NSLog(...) NSLog(__VA_ARGS__)

      #else

     #    define NSLog(...) {}

      #endif
Abhishek Bedi
  • 5,205
  • 2
  • 36
  • 62
1

You can remove your NSLog statements using sed and grep. The basic idea is to grep all lines containing NSLog statements and then delete them using sed.

Using sed and grep might be new to you, but it's very helpful in the long run!

Here's some code I think should work, but backup your work first: grep -Ev 'NSLog'.

Community
  • 1
  • 1
ryyst
  • 9,563
  • 18
  • 70
  • 97