Xcode中Info.plist读取配置文件环境变量

1.在Info.plist中添加("add row")一项或者直接在某个key中把对应的value改为

$(变量名)  如“$(APP_VERSION_TEXT)”

2.COMMAND+N 创建一个config文件

写入内容

3.使用该config

选择需要的config,

因为我创建了2个Dev和Build  选择其中之一即可。

oc中读取:

  NSString *bundlePath = [[NSBundle mainBundle] pathForResource:@"Info" ofType:@"plist"];
  NSMutableDictionary *infoDict = [NSMutableDictionary dictionaryWithContentsOfFile:bundlePath];
  NSString *version = [infoDict objectForKey:@"CFBundleShortVersionString"];

  NSString *isProd = [infoDict objectForKey:@"isProd"];

  //NSLog(@"**%@",infoDict);
  NSLog(@"**%@",isProd1);

参考:https://www.jianshu.com/p/9b8bc8351223

猜你喜欢

转载自blog.csdn.net/ky1in93/article/details/81737551