A Swift μ-Library for determining app version
AppVersion is a simple little library that offers a structured type around typical app versioning. It currently supports the format of major.minor.patch
, a subspecies of Semver.
let currentAppVersion: AppVersion? = .fromBundle
An AppVersion
can conveniently be created from a String
:
let appVersion: AppVersion = "1.2.3"
Comparison operations (==
, >
, <
, etc.) work seamlessly:
let minimumAppVersion: AppVersion = "2.0.0"
guard let currentAppVersion: AppVersion = .fromBundle, currentAppVersion >= minimumAppVersion else {
// send user to App Store
}
To determine whether the version is stable / has a public API:
appVersion.isStable
To detemrine the next version:
appVersion.nextMajor() // i.e. 1.2.3 goes to 2.0.0
appVersion.nextMinor() // i.e. 1.2.3 goes to 1.3.0
appVersion.nextPatch() // i.e. 1.2.3 goes to 1.2.4
See Adding Package Dependencies to Your App. Point to the desired version or the trunk
branch.
pod 'AppVersion', :git => 'https://github.com/hkellaway/AppVersion.git', :branch => 'trunk'
AppVersion was created by Harlan Kellaway.
AppVersion is available under the MIT license. See the LICENSE file for more info.