我有一个有两个目标的应用程序,小版/目标里面有谷歌admob广告。现在我使用下面的代码来处理。
//App_Prefix.pch
#define _lite在appDelegate中
// AppDelegate.m
#ifdef _lite
@import GoogleMobileAds;
#endif
@implementation AppDelegate编译项目时是否可以检测目标。下面的代码可以检测到目标,
//-------------detect target
#define _lite [ [[[NSProcessInfo processInfo]environment]objectForKey:@"TARGET"] isEqualToString:@"lite"]但是它不适合以前的零件。
@implementation 欢迎您的评论
发布于 2018-01-25 14:25:06
选项1
Use可以为每个目标定义Preprocessor Macros。
Build Settings,去Preprocessor MacrosAPP_TARGET_A )(调试/发布)
现在,您可以在.pch文件中定义的宏中使用它。
#define APP_TARGET_A
@implementation
#endif选项2
您可以为每个目标拥有不同的.pch文件。复制.pch文件,例如Target_A_Prefix.pch Target_B_Prefix.pch,并将其添加到项目中(取消选中所有目标)。
在Build中,转到Prefix Header并为每个配置设置到.pch的路径。对所有目标都做同样的事情。

https://stackoverflow.com/questions/48444892
复制相似问题