Select General > iPhone Storage. Wait a moment, and the screen will populate with storage stats for each of your installed apps. Tap the app you want to see the version number for. Next to the app icon you'll see the app name, the version number you're looking for.
These are the actual software version numbers, as opposed to the values used for marketing. If you go to Xcode menu > About Xcode, you'll see the Version and Build numbers. If you hit the More Info... button you'll see a bunch of different versions. Since the More Info...
You can get the version and build numbers as follows:
let version = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as! String
let build = Bundle.main.object(forInfoDictionaryKey: kCFBundleVersionKey as String) as! String
or in Objective-C
NSString * version = [[NSBundle mainBundle] objectForInfoDictionaryKey: @"CFBundleShortVersionString"];
NSString * build = [[NSBundle mainBundle] objectForInfoDictionaryKey: (NSString *)kCFBundleVersionKey];
I have the following methods in a category on UIApplication
:
extension UIApplication {
static var appVersion: String {
return Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as! String
}
static var appBuild: String {
return Bundle.main.object(forInfoDictionaryKey: kCFBundleVersionKey as String) as! String
}
static var versionBuild: String {
let version = appVersion, build = appBuild
return version == build ? "v\(version)" : "v\(version)(\(build))"
}
}
Gist: https://gist.github.com/ashleymills/6ec9fce6d7ec2a11af9b
Here's the equivalent in Objective-C:
+ (NSString *) appVersion
{
return [[NSBundle mainBundle] objectForInfoDictionaryKey: @"CFBundleShortVersionString"];
}
+ (NSString *) build
{
return [[NSBundle mainBundle] objectForInfoDictionaryKey: (NSString *)kCFBundleVersionKey];
}
+ (NSString *) versionBuild
{
NSString * version = [self appVersion];
NSString * build = [self build];
NSString * versionBuild = [NSString stringWithFormat: @"v%@", version];
if (![version isEqualToString: build]) {
versionBuild = [NSString stringWithFormat: @"%@(%@)", versionBuild, build];
}
return versionBuild;
}
Gist: https://gist.github.com/ashleymills/c37efb46c9dbef73d5dd
Here's what worked on Xcode 8, Swift 3:
let gAppVersion = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") ?? "0"
let gAppBuild = Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") ?? "0"
print("Version: \(gAppVersion)")
print("Build: \(gAppBuild)")
In Objective C:
1)For getting App version you have to use a:
NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
2)For getting Build version you have to use a:
NSString *buildVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
[Swift version: 5.2]
All iOS apps must store an app version number in their Info.plist file, but there’s no build-in way to get that as a string you can use in your code.
I have created one small extension to UIApplication that reads the Info.plist file and returns a version number automatically.
Here’s the code:
extension UIApplication {
static var appVersion: String? {
return Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String
}
}
Inside Your Controller
@IBOutlet weak var tv_version: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
//Display Version
setUpCurrentVersion()
}
func setUpCurrentVersion(){
tv_version.text = "v" + UIApplication.appVersion!
}
In Swift, you can get bundle version by using:
let info:NSDictionary = NSBundle.mainBundle().infoDictionary!
let version:String = info.objectForKey("CFBundleShortVersionString") as! String
versionLabel.text = "Version:" + version
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With