ios - 如何在build设置中从 Info.plist 中读取值?

标签 ios plist

目前,我有一个自定义的用户定义的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/

相关文章:

ios - 播放/暂停按钮未出现在Carplay控制台中

objective-c - 检查文件是否存在时出错

ios - 在 .plist 文件中使用 .xcconfg 值

objective-c - 在文本中使用换行符时,UITableViewCell 删除按钮会搞乱 textLabel

ios - 是否可以重用 cellForItemAtIndexPath :?

ios - Google 街景应用程序(非 Google map )的 URL 架构

iphone - 具有不同字符串选项的Plist

ios - 以编程方式更改应用名称

iphone - 无法从 iOS 中创建的 plist 文件中获取值

ios - 无法将第二个选项卡栏添加到选项卡栏 Controller View