Use Xcode $ {PRODUCT_NAME} inside header files

I have a common header file that I include in every project. Among other things, it defines a preprocessor macro to easily get a link to the application delegate. The problem is that the class name of the application delegate changes from project to project, as it includes the product name (AppDelegate). So I wonder, is it possible to somehow use $ {PRODUCT_NAME} or a similar macrostructure in the header files?

+3
source share
1 answer

Install the preprocessor macros in the Xcode build settings.

APPDELEGATE_CLASS=$(PRODUCT_NAME)AppDelegate

In xcconfig,

GCC_PREPROCESSOR_DEFINITIONS = APPDELEGATE_CLASS=$(PRODUCT_NAME)AppDelegate

Then you can use the APPDELEGATE_CLASS macro in your code.

@interface APPDELEGATE_CLASS : NSObject <UIApplicationDelegate> {
+6
source

All Articles