Refer to build number or version number in code

后端 未结 7 1410
眼角桃花
眼角桃花 2020-12-08 13:21

It\'s easy to set the build and version numbers manually in Xcode, and I learned how to increment them with a macro at build time. But how do I reference their values in cod

7条回答
  •  执笔经年
    2020-12-08 14:07

    Since those values are stored in your app's Info.plist you can read then via the methods provided on NSBundle:

    NSString * version = [[NSBundle mainBundle] objectForInfoDictionaryKey: CFBundleShortVersionString];
    

    See Accessing bundles contents as the authoritative reference on getting data from your Info.plist file and Core Foundation keys for available Info.plist keys.

提交回复
热议问题