Refer to build number or version number in code

后端 未结 7 1416
眼角桃花
眼角桃花 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 13:52

    NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
    NSString *appVersion = [infoDict objectForKey:@"CFBundleShortVersionString"]; // example: 1.0.0
    NSString *buildNumber = [infoDict objectForKey:@"CFBundleVersion"]; // example: 42 
    

提交回复
热议问题