How do I get the App version and build number using Swift?

前端 未结 30 981
暖寄归人
暖寄归人 2020-12-22 15:21

I have an IOS app with an Azure back-end, and would like to log certain events, like logins and which versions of the app users are running.

How can I return the ver

30条回答
  •  时光取名叫无心
    2020-12-22 15:37

    for anyone interested, there's a nice and neat library called SwifterSwift available at github and also fully documented for every version of swift (see swifterswift.com).

    using this library, reading app version and build number would be as easy as this:

    import SwifterSwift
    
    let buildNumber = SwifterSwift.appBuild
    let version = SwifterSwift.appVersion
    

提交回复
热议问题