FreeAsInBeer
FreeAsInBeer

Reputation: 12979

Conditionally compiled NSLog alternative in framework class for use outside of framework

I have an NSLog alternative that outputs the class it's called from as well as the line number and method (selector) called PLog in a class called PLogging. It's the exact same as the DLog taken from here with the exception of the name change. The advantage of DLog as it is written is that when compiled under Release mode, the log call is changed to a comment, negating the performance impact you would otherwise be subject to. I want to be able to use this and keep it within the framework, but be able to call it from the projects I add the framework to. But still have the log calls compiled to comments when in Release mode. Is this possible?

Upvotes: 1

Views: 415

Answers (2)

Nick Weaver
Nick Weaver

Reputation: 47241

I would suggest a white list approach: add a preprocessor definition to your debug configurations which enables DLog/Plog to log to the console. In every other case it turns to comments.

Please have a look at this blog post which seems to point a finger at your problem. Of course, assuming that you don't want to change the way you are achieving your functionality: macros. I'm quoting abit: "An example of the basic problem is you want to link to a library that has both a Debug and a Release version. So in your application you want your Debug version to link to the Debug version of the library, and you want your Release version to link the Release version of the library."

I would rather tend to use targets for that, the trouble does look uncomfortable.

Upvotes: 2

Jim
Jim

Reputation: 73936

Third-party frameworks aren't allowed by the App Store. I assume you've got a static library or source files that you add to your apps with a cross-project reference?

If you've set your library project up with a debug flag set for your Debug configuration and unset for your Release configuration, then all you have to do is use the same configuration names for your app project, and the library will be built with the same configuration.

Upvotes: 0

Related Questions