More detailed explanation (for smaller version, check TL;DR in the end):
I created a framework that I made available in Github. In it, there are 7 Macros that define how the framework should be compiled. I can't just replace them with static const
's because 6 of those Macros are used to remove some things from the framework in compiling time.
Those Macros may be divided in groups:
Group 1) Use framework when available
#define USE_THE_METAL_FRAMEWORK_WHEN_AVAILABLE true
#define USE_THE_OPENGL_FRAMEWORK_WHEN_AVAILABLE true
Those defines make the framework use the Metal and OpenGL frameworks even if they weren't added to the project. That's done using dlopen
. More details below:
I use this so those frameworks can be used only if they are available, so the dev can build his/her app for macOS 10.6 and still use Metal if it's available in the system. The problem is: if your app binary calls dlopen
somewhere, you can't add it to the Apple Store (even if you don't really use the function that uses it), so users should be able to remove that from the code if they want. That removes some of the framework functionalities, but make it capable of being submitted.
Group 2) I'm importing the framework
#define IM_IMPORTING_THE_METAL_FRAMEWORK false
#define IM_IMPORTING_THE_OPENGL_FRAMEWORK false
Those defines make the framework really use Metal and OpenGL frameworks, without using dlopen
. In that way, it can be submitted to the Apple Store and still use the features that were mentioned before.
Group 3) Behaviour changes
#define USER_NOTIFICATIONS_SHOULD_SHOW_A_BIGGER_ICON true
#define NSDEBUGLOG_SHOULD_PRINT_TO_A_DESKTOP_FILE_TOO true
The first one can also cause problems in the Apple Store, and the second one is only for debugging purposes.
And at last...
Group 4) Should be released in the Apple Store
#define I_WANT_TO_BE_RELEASED_IN_APPLE_STORE false
That one is used for that:
#if I_WANT_TO_BE_RELEASED_IN_APPLE_STORE == true
#define USER_NOTIFICATIONS_SHOULD_SHOW_A_BIGGER_ICON false
#define USE_THE_METAL_FRAMEWORK_WHEN_AVAILABLE false
#define USE_THE_OPENGL_FRAMEWORK_WHEN_AVAILABLE false
#endif
It automatically disables the three defines that may cause problems with the Apple Store.
Still, those who use Travis-CI for example are not capable of changing the framework unless they completely copy it to the project. To solve this problem (or at least reduce it), 5 of those 7 defines could be changed by a file in the main project, for example. If anyone has other suggestions that may solve the issue, I'm listening.
(Optional) If this could be done in a way that the user may be warned (by Xcode or by an error in compiling time) that he/she needs to set those variables that would be great, since this would avoid problems with users that may need to set those Macros.
TL;DR: Is it possible to change the values of some Macros within a framework without modifying the framework itself?