1

Am using Cocoapods and trying to configure the CocoaLumberjack library to be only there for the Debug build configuration.

What I want to happen is that when I build for release, the CocoaLumberjack library is not compiled and all the log statements are ignored.

Was able to configure the CocoaLumberjack pod to not be included in 'release' using this statement in the podfile:

pod 'CocoaLumberjack', '2.0.0-rc2', :configurations => ['Debug']

However all the log statements end up becoming errors since their source cannot be found.

So was wondering whether it is possible to only have CocoaLumberjack for the debug build configuration and when building to release it is as if both the library and log statements were never there.

Advice and suggestions are welcome.

Pao13
  • 69
  • 1
  • 3

1 Answers1

0

Make sure that the DEBUG macro is set to 1 when in debug mode in build settings. (it's ON in default)

enter image description here

then just do:

#ifdef DEBUG
   // log here
#endif

this way the source code between #ifdef and #endif will be compiled only if DEBUG is 1

Preprocessor directives are really useful.

michal.ciurus
  • 3,616
  • 17
  • 32
  • Your answer is obviously correct, but it should be mentioned that debugging different code than you ship can lead to a range of new problems. – iCaramba Mar 16 '15 at 22:37