proxpero / AppUpdater

Represent an app's version. Fetch the App Store version. Compare versions. Get the bundle version.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AppUpdater

A package to simply fetch an app's current store version (major.minor.patch). This can be used to test whether a user has the same version of your app as is in the App Store.

That's all there is to it. Playground included. Tests included.

import AppUpdater
import PlaygroundSupport

PlaygroundPage.current.needsIndefiniteExecution = true

let earlierVersion = AppVersion(major: 2, minor: 8, patch: 1)
let laterVersion = AppVersion("2.9.110")!
let currentVersion = AppVersion(major: 2, minor: 9, patch: 23)

assert(currentVersion > earlierVersion)
assert(laterVersion > currentVersion)

AppVersion.storeVersion(bundleId: "com.myCompany") { result in
    switch result {
    case .success(let (storeVersion, storeUrl)):
        if currentVersion < storeVersion {
            print("Download the latest version here: \(storeUrl)")
        }
        
    case .failure(let error):
        print(error.localizedDescription)
    }
    PlaygroundPage.current.finishExecution()
}

In your app, you can load a device's current app version from the main bundle using the extension:

import Foundation
let version = Bundle.main.appVersion // This fails in a playground because playgrounds don't have versions.

About

Represent an app's version. Fetch the App Store version. Compare versions. Get the bundle version.


Languages

Language:Swift 100.0%