Question

I have built a framework to make it public and use with other project. It has built-in logs. So I am trying to give to an application developer (which wants to use my framework) an ability to enable/disable logs in the framework. The best way I was thinking about is that he can add a preprocessor macros definitions to the application's build settings like:

ENABLE_FRAMEWORK_LOGS = 1

so I could do something like this:

#ifdef ENABLE_FRAMEWORK_LOGS
    NSLog(12345);
#endif

but I have a problem: My framework does not see predefined macros in application's build settings, it can see only predefined macros in the framework's build settings

so my question is: is it possible at all? and if it is not - what is the right way to do it?

thanks

Was it helpful?

Solution

If you are releasing your source code and you believe users will just drop in your source into their project then you can use the preprocessor macros because your source will be compiled when they build their app.

If however your releasing the compiled framework to the public then no you can't use preprocessor macros as they are only used at compile time. You would have to have the ability to allow a user to turn it off via an API call to your framework or the ability for your framework to read in a configuration file / plist.

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