Search code examples
iosobjective-cmacrosxcode5nslog

Using preprocessor macro to decide if app build is for debug or release


I want to log some events for debug builds. I have added below code in .pch file to log using DLog() in debug only. I have added IS_DEBUG macro in build setting.

#ifdef IS_DEBUG
    #define DLog(...) NSLog(__VA_ARGS__)
#else
    #define DLog(...)
#endif

To test if it works or not, I removed IS_DEBUG from build setting and ran app. Issue is that it always logs irrespective of debug/release app.

Please note that I tried changing the name of both DLogmethod and preprocessor macro to see it is due to same macro or method is defined somewhere else. But still it gives same issue, means same macro or method is not used else where.


Solution

  • Bryan's answer helped me in solving this issue. Only cleaning project and Xcode cache did not work for me. I reset the simulator and cleaned project. It got it worked.