开发者

Use XCode's ${PRODUCT_NAME} inside header files

开发者 https://www.devze.com 2023-03-03 13:13 出处:网络
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 o

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> {
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号