0

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

Ezeki
  • 1,519
  • 10
  • 17

1 Answers1

2

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.

Shaun
  • 412
  • 2
  • 7
  • yes, this is true. My framework is compiled, so it uses its own preprocessor definitions. So I did this through api calls. Your answer is right, thank you. – Ezeki Jan 17 '13 at 16:02