[英]How can you read values from Info.plist in build settings?
Currently, I have a custom user defined build settings in which I set the DISPLAY_NAME. 目前,我有一个自定义的用户定义的构建设置,其中设置了DISPLAY_NAME。
Then, in the General tab of Build Settings, in the display name column, I fetch this value as $(DISPLAY_NAME) from my user defined build settings. 然后,在“构建设置”的“常规”选项卡的“显示名称”列中,从用户定义的构建设置中将此值提取为$(DISPLAY_NAME)。
I want to instead read the Display Name and set the general build settings from my Info.plist file. 我想改为读取显示名称,然后从我的Info.plist文件中设置常规构建设置。 How can I do this?
我怎样才能做到这一点?
you can use the following code. 您可以使用以下代码。
Read info.plist file. 读取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.
infoDictionary:从捆绑软件的Info.plist文件构造的字典,其中包含有关接收者的信息。
Read a custom .plist file 读取自定义.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];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.