Read version from Info.plist

John Smith picture John Smith · Oct 30, 2010 · Viewed 41.4k times · Source

I want to read the bundle version info from Info.plist into my code, preferably as a string. How can I do this?

Answer

gcamp picture gcamp · Oct 30, 2010

You can read your Info.plist as a dictionary with

[[NSBundle mainBundle] infoDictionary]

And you can easily get the version at the CFBundleVersion key that way.

Finally, you can get the version with

NSDictionary* infoDict = [[NSBundle mainBundle] infoDictionary];
NSString* version = [infoDict objectForKey:@"CFBundleVersion"];