Is there a way to read the app's bundled plist file, I am wanting to pull the value for Bundle version.
Asked
Active
Viewed 2.1k times
3 Answers
123
See Getting the Bundle’s Info.plist Data.
[[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey];
should get you the bundle version.

Ole Begemann
- 135,006
- 31
- 278
- 256
-
Some more information can be found in (a duplicate): [How can I check the bundle version of our application programmatically?](http://stackoverflow.com/questions/2657477/how-can-i-check-the-bundle-version-of-our-application-programmatically) – Guy Oct 28 '14 at 10:28
-
3`[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"];` will get you the short version string as shown in the answer below (just posting the objc version) – smileham Apr 12 '16 at 15:55
-
hi OleB, the document link is outdated – Quang Vĩnh Hà May 28 '19 at 06:27
16
In Swift you can use:
let bundleVersion = Bundle.main.object(forInfoDictionaryKeykCFBundleVersionKey as String) as! String
or:
let bundleVersion = Bundle.main.infoDictionary?[kCFBundleVersionKey as String] as! String
If you want the short bundle versions string, you can use:
let shortBundleVersion = Bundle.main.object(forInfoDictionaryKey:"CFBundleShortVersionString") as! String
-1
#define APP_VERSION [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString*)kCFBundleVersionKey]

Fabio Poloni
- 8,219
- 5
- 44
- 74

Hardik Darji
- 3,633
- 1
- 30
- 30