Swiftpack.co - proxpero/AppUpdater as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by proxpero.
proxpero/AppUpdater 1.0.0
Represent an app's version. Fetch the App Store version. Compare versions. Get the bundle version.
⭐️ 1
🕓 3 years ago
.package(url: "https://github.com/proxpero/AppUpdater.git", from: "1.0.0")

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.

GitHub

link
Stars: 1
Last commit: 3 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

Initial Release
3 years ago

The first release. Represent a version. Fetch the App Store version. Compare versions. Get the bundle version. What else is there?

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics