目前,我有一个自定义的用户定义的build设置,我在其中设置了 DISPLAY_NAME。
然后,在build设置的常规选项卡中,在显示名称列中,我从用户定义的build设置中将此值作为 $(DISPLAY_NAME) 获取。
我想改为读取显示名称并从我的 Info.plist 文件中设置一般build设置。我怎样才能做到这一点?
最佳答案
您可以使用以下代码。
阅读 info.plist 文件。
NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
NSString *value = [infoDict objectForKey:@"keyName"];
infoDictionary: A dictionary, constructed from the bundle's Info.plist file, that contains information about the receiver.
读取自定义 .plist 文件
NSString *file = [[NSBundle bundleForClass:[self class]] pathForResource:"nameOfPlist" ofType:@"plist"];
if (!file) {
NSLog(@"Please add a plist config file to your project.");
return nil;
}
NSDictionary *plistDict = [NSDictionary dictionaryWithContentsOfFile:file];
关于ios - 如何在build设置中从 Info.plist 中读取值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47937112/