Question

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.

Was it helpful?

Solution 2

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.

OTHER TIPS

In Xcode you are able to define Schemes. Each scheme can build to a specific configuration, usually at least Debug and Release. You can specify which you would like to use in the scheme manager in Xcode.

Next, in your targets configuration, you can change the macros that are defined for which configuration you'd like it to be associated with. In your case this would be 'IS_DEBUG'. Most likely you'd want to do this for the Debugging configtation, then create a scheme to build that configuration.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top