12

I want to get the iOS version of the devices which my app is installed on them . Actually I think it is the SDK version of my app . How can I get that by code ? Does it have any function or not ? And also excuse me if I can't explain it good â˜šī¸ .

2 Answers2

24

Use this func for swift 4,

1. Get app version that is in the genral

func getAppInfo()->String {
    let dictionary = Bundle.main.infoDictionary!
    let version = dictionary["CFBundleShortVersionString"] as! String
    let build = dictionary["CFBundleVersion"] as! String
    return version + "(" + build + ")"
}

2. Get app current name that is in general

func getAppName()->String {
    let appName = Bundle.main.object(forInfoDictionaryKey: "CFBundleDisplayName") as! String
    return appName
}

3. Get device iOS version in which app is running.

func getOSInfo()->String {
    let os = ProcessInfo.processInfo.operatingSystemVersion
    return String(os.majorVersion) + "." + String(os.minorVersion) + "." + String(os.patchVersion)
}

Input

    print("OS Version: \(getOSInfo())")
    print("App version: \(getAppInfo())")
    print("App Name: \(getAppName())")

Output:

enter image description here

Saren Inden
  • 3,450
  • 4
  • 32
  • 45
dahiya_boy
  • 9,298
  • 1
  • 30
  • 51
11

Use the below code to get the version:

swift 4

let systemVersion = UIDevice.current.systemVersion

Objective c

[[UIDevice currentDevice] systemVersion]
vivekDas
  • 1,248
  • 8
  • 12