iosxcodeversionbuild-numbers

Xcode Gettings Version & Build Number


I want to print both the version and build number into my app on the app's Info and Credits screen. I've entered 1.2 in the "Version Number" on the summary page, and "D03" into the "Build Number" on summary page.

I then found this code snippet to print them,

NSString * appVersionString = [[NSBundle mainBundle]
                                   objectForInfoDictionaryKey:@"CFBundleVersion"];

However this only seems to print the value in "Build Number" not the value in version number. How do I access both the Build and Version numbers?


Solution

  • I believe what you want to use is CFBundleShortVersionString. Here is the documentation on what you are looking for:

    Apple's documentation