How to display the current project version of my App to the user?

后端 未结 6 1511
遥遥无期
遥遥无期 2020-12-01 13:01

I would like to add the current version into the \"about\" section of my app. As seen in this attached screenshot Apple offers versioning.

How do you display these s

6条回答
  •  我在风中等你
    2020-12-01 13:09

    After further searching and testing, I found the solution myself.

    NSDictionary* infoDictionary = [[NSBundle mainBundle] infoDictionary];
    NSLog(@"%i Keys:  %@", [infoDictionary count],
                 [[infoDictionary allKeys] componentsJoinedByString: @" ,"]);
    

    This snipplet gave me the following output:

    20 Keys : NSBundleResolvedPath ,CFBundleVersion ,NSBundleInitialPath ,CFBundleIdentifier ,NSMainNibFile ,CFBundleIconFile ,CFBundleInfoPlistURL ,CFBundleExecutable ,DTSDKName ,UIStatusBarStyle ,CFBundleDevelopmentRegion ,DTPlatformName ,CFBundleInfoDictionaryVersion ,CFBundleSupportedPlatforms ,CFBundleExecutablePath ,CFBundleDisplayName ,LSRequiresIPhoneOS ,CFBundlePackageType ,CFBundleSignature ,CFBundleName

    So the solution is as simple as:

    NSString *version =[[[NSBundle mainBundle] infoDictionary] valueForKey:@"CFBundleVersion"];
    

    However, this is not the Current Project Version as seen in the screenshot but the Bundle Version of the plist file.

提交回复
热议问题