Read version from Info.plist

后端 未结 5 1481
北荒
北荒 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:30

    Now in iOS 8 both fields are necessary. Earlier it works without the CFBundleShortVersionString. But now it is a required plist field to submit any app in app store. And kCFBundleVersionKey is compared for uploading every new build, which must be in incremental order. Specially for TestFlight builds. I do it this way,

    NSString * version = nil;
        version = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
        if (!version) {
            version = [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey];
        }
    

提交回复
热议问题