Read version from Info.plist

后端 未结 5 1560
北荒
北荒 2021-01-30 02:49

I want to read the bundle version info from Info.plist into my code, preferably as a string. How can I do this?

5条回答
  •  情书的邮戳
    2021-01-30 03:25

    You can read your Info.plist as a dictionary with

    [[NSBundle mainBundle] infoDictionary]
    

    And you can easily get the version at the CFBundleVersion key that way.

    Finally, you can get the version with

    NSDictionary* infoDict = [[NSBundle mainBundle] infoDictionary];
    NSString* version = [infoDict objectForKey:@"CFBundleVersion"];
    

提交回复
热议问题