OC-开发案例收集

iOS进阶01:多环境配置

2021-02-03  本文已影响0人  黑白森林无间道

多环境配置的三种方式:

多Target配置

多 scheme + 多 configuration

NSString *path = [NSBundle.mainBundle pathForResource:@"Info" ofType:@"plist"];
    NSDictionary *infoDic = [[NSDictionary alloc] initWithContentsOfFile:path];
    NSLog(@"====%@", infoDic[@"HOST_URL"]);
image
image

多 scheme + xcconfig文件配置

通过下图发现,pod 就是通过 xcconfig文件进行配置的

image
HOST_URL = www.debug.com
image
NSString *path = [NSBundle.mainBundle pathForResource:@"Info" ofType:@"plist"];
    NSDictionary *infoDic = [[NSDictionary alloc] initWithContentsOfFile:path];
    NSLog(@"====%@", infoDic[@"HOST_URL"]);
image
HOST_URL = www.debug.com
// OTHER_LDFLAGS 是 Other Linker Flags 的缩写
OTHER_LDFLAGS = -framework "AFNetworking"
image
【注意】Xcode Build Settings更多缩写内容,可以通过这个网址查询地址

xcconfig文件冲突解决

使用自己的 xcconfig文件,运行pod install时,报错如下:

image
上一篇 下一篇

猜你喜欢

热点阅读