Use XCode's ${PRODUCT_NAME} inside header files
I have a generic header file that I include in every project. Among other things, it defines a preprocessor macro for easily obtaining a reference to the app delegate. The problem is, the class name of the app delega开发者_开发问答te changes from project to project, as it includes the product name (AppDelegate). Therefore I wonder if it's somehow possible to use ${PRODUCT_NAME}, or a similar macro construct, in header files?
Set Preprocessor Macros in Xcode Build Settings.
APPDELEGATE_CLASS=$(PRODUCT_NAME)AppDelegate
In xcconfig,
GCC_PREPROCESSOR_DEFINITIONS = APPDELEGATE_CLASS=$(PRODUCT_NAME)AppDelegate
Then you can use APPDELEGATE_CLASS macro in your code.
@interface APPDELEGATE_CLASS : NSObject <UIApplicationDelegate> {
精彩评论