Popularity
1.0
Stable
Activity
0.0
Stable
30
4
3

Code Quality Rank: L5
Programming language: Swift
License: MIT License
Tags: Utility    
Latest version: v0.3.0

VersionsTracker alternatives and similar libraries

Based on the "Utility" category.
Alternatively, view VersionsTracker alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of VersionsTracker or a related project?

Add another 'Utility' Library

README

VersionsTracker

CI Status Version License Platform

Keeping track of version installation history made easy.

Features

  • Track not just marketing version, but also build number and install date
  • Track both App and OS version
  • Access current version
  • Check for version updates and first launch
  • No use as Singleton required
  • Ability to use custom NSUserDefaults (e.g. for sharing it with extensions )

Example

To run the example project, clone the repo, and run pod install from the Example directory first. Play with the Sample app's version and build numbers.

Requirements

Installation

CocoaPods

VersionsTracker is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "VersionsTracker"

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. Add the following line to your Cartfile:

github "martnst/VersionsTracker"

Usage

Initialization

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

    if iDontMindSingletons {
        VersionsTracker.initialize(trackAppVersion: true, trackOSVersion: true)
    }
    else {
        // make sure to update the version history once once during you app's life time
        VersionsTracker.updateVersionHistories(trackAppVersion: true, trackOSVersion: true)
    }

    return true
}

Get the current versions with build and install date

let versionsTracker = iDontMindSingletons ? VersionsTracker.sharedInstance : VersionsTracker()

let curAppVersion : Version = versionsTracker.appVersion.currentVersion
print("Current marketing version is \(curAppVersion.versionString) (Build \(curAppVersion.buildString)) and was first launched \(curAppVersion.installDate)")

Get the version history

let versionsTracker = iDontMindSingletons ? VersionsTracker.sharedInstance : VersionsTracker()

let appVersions: [Version] = versionsTracker.appVersion.versionHistory
let firstOSVerion : Version = versionsTracker.osVersion.versionHistory.first!
print("The very first time the app was launched on iOS \(firstOSVerion.versionString) on \(firstOSVerion.installDate)")

Check version changes easily

let versionsTracker = iDontMindSingletons ? VersionsTracker.sharedInstance : VersionsTracker()

switch versionsTracker.appVersion.changeState {
case .installed:
    // 🎉 Sweet, a new user just installed your app
    // ... start tutorial / intro
    print("🆕 Congratulations, the app is launched for the very first time")

case .notChanged:
    // 😴 nothing as changed
    // ... nothing to do
    print("🔄 Welcome back, nothing as changed since the last time")

case .updated(let previousVersion: Version):
    // 🙃 new build of the same version
    // ... hopefully it fixed those bugs the QA guy reported
    print("🆙 The app was updated making small changes: \(previousVersion) -> \(versionTracker.currentVersion)")

case .upgraded(let previousVersion):
    // 😄 marketing version increased
    // ... migrate old app data
    print("⬆️ Cool, its a new version: \(previousVersion) -> \(versionTracker.currentVersion)")

case .downgraded(let previousVersion):
    // 😵 marketing version decreased (hopefully we are not on production)
    // ... purge app data and start over
    print("⬇️ Oohu, looks like something is wrong with the current version to make you come back here: \(previousVersion) -> \(versionTracker.currentVersion)")
}    

Since the build is also kept track off, it enables detecting updates of it as well. However, the build fraction of a version is treated as an arbitrary string. This is to support any build number, from integer counts to git commit hashes. Therefor there is no way to determine the direction of a build change.

Compare Version

let versionsTracker = iDontMindSingletons ? VersionsTracker.sharedInstance : VersionsTracker()
let curAppVersion : Version = versionsTracker.appVersion.currentVersion

curAppVersion >= Version("1.2.3")
curAppVersion >= "1.2.3"
Version("1.2.3") < Version("3.2.1")
curAppVersion != Version("1.2.3", buildString: "B19")

Versions with the same marketing version but different build are not equal.

Author

Martin Stemmle, [email protected]

License

VersionsTracker is available under the MIT license. See the LICENSE file for more info.


*Note that all licence references and agreements mentioned in the VersionsTracker README section above are relevant to that project's source code only.