Xcode中Info.plist讀取配置檔案環境變數
阿新 • • 發佈:2018-11-10
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);