Latest 1.0.0
Homepage https://github.com/notohiro/SwiftyVersionTracker
License MIT
Platforms ios 8.0, requires ARC
Authors

CocoaPods Compatible
Carthage Compatible
Platform
Twitter

Quick Look

With SwiftyVersionTracker, you can track which versions previously installed. Convenient methods are also available.

let tracker = try! SwiftyVersionTracker<SwiftyVersionIntInt>()

if tracker.isFirstLaunchEver {
  // do something
  // e.g. shows welcome screen
}

if tracker.isFirstLaunchForVersion {
  // do something
  // e.g. shows release note
}

if tracker.last?.major == 1 {
  // do something
  // e.g. migrate database
}

Features

  • [x] Track which versions of your application previously installed
  • [x] Support any type of versioning literals with Swift Generics
  • [x] Most of use case is covered out of the box with SwiftyVersionIntInt

Usage

Parameters

  • isFirstLaunchEver: Bool returns whether it’s first launch or not.
  • isFirstLaunchForVersion: Bool returns whether it’s first launch for version or not.
  • isFirstLaunchForBuild: Bool returns whether it’s first launch for build or not.
  • current: T represents current version.
  • previous: T? represents previously installed version. This value never change until different version will be launched.
  • first: T represents first version user installed.
  • last: T? represents a version which last launched.
  • history: [T] represents all the history of installed versions.

What’s T?

SwiftyVersionTracker is build on Protocol Oriented Programming. We defined SwiftyVersion as protocol, so you can use SwiftyVersionTracker with any type of versioning rules and literals.

SwiftyVersion

Before using SwiftyVersionTracker, you must implement class or struct which comfirms to SwiftyVersion. SwiftyVersion is simple protocol as described below.

public protocol SwiftyVersion: Equatable {
    associatedtype VersionLetters: Comparable
    associatedtype BuildLetters: Comparable

    var major: VersionLetters { get }
    var minor: VersionLetters { get }
    var release: VersionLetters { get }
    var build: BuildLetters { get }

    init(versionString: String?, buildString: String?) throws
}

If you need more explanation about software versioning, see Wikipedia. 😃

SwiftyVersionIntInt: SwiftyVersion

OK, We know you wanna just using SwiftyVersionTracker, without any effort as possible, and most of applications using just numbers something like version: 1.2.3, build: 10. For you, we implemented SwiftyVersionIntInt which supports versioning rule using Integers only. 😉

let version = try! SwiftyVersionIntInt(versionString: "1.2.3", buildString: "4")

XCTAssertEqual(version.major, 1)
XCTAssertEqual(version.minor, 2)
XCTAssertEqual(version.release, 3)
XCTAssertEqual(version.build, 4)

SwiftyVersionTracker

Finally, it’s time to use SwiftyVersionTracker!! You have two ways to initialize SwiftyVersionTracker.

1.With Bundle

First way is with bundle, and this is the best way for most applications. Initialize SwiftyVersionTracker without parameters, initializer will try initialize YourVersion: SwiftyVersion
with bundle version strings. Bundle version strings are defined in target general settings in Xcode, just like below.

And example code is below.

let tracker = try! SwiftyVersionTracker<YourVersion>()

Looks pretty cool, huh? 😆

2.With Your Own

If you have version strings in database, code or something like that, initialize SwiftyVersionTracker with parameters versionString and buildString.

Example below.

let tracker = try! SwiftyVersionTracker<YourVersion>(versionString: "1.2.3", buildString: "a123")

Within App Extensions

If you wanna track versions even within App Extension, you can specify userDefaults parameter for sharing tracking data between application and extension.

Requirements

  • iOS 8.0+
  • Xcode 8.0+

Installation

SwiftyVersionTracker is available through CocoaPods and Carthage.

CocoaPods

To install, simply add the following line to your Podfile:

platform :ios, '8.0'
use_frameworks!

pod 'SwiftyVersionTracker'

Carthage

To integrate NowCastMapView into your Xcode project using Carthage, specify it in your Cartfile:

github "notohiro/SwiftyVersionTracker"

Run carthage update to build the framework and drag the built SwiftyVersionTracker.framework into your Xcode project.

Have Fun?🎉

Don’t forget ⭐️, and if you like this, thanks donation for coffee. ☕️

Donate

License

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

Latest podspec

{
    "name": "SwiftyVersionTracker",
    "version": "1.0.0",
    "summary": "With SwiftyVersionTracker, you can track which versions previously installed. Convenient methods are also available.",
    "homepage": "https://github.com/notohiro/SwiftyVersionTracker",
    "license": "MIT",
    "authors": {
        "Hiroshi Noto": "[email protected]"
    },
    "source": {
        "git": "https://github.com/notohiro/SwiftyVersionTracker.git",
        "tag": "1.0.0"
    },
    "platforms": {
        "ios": "8.0"
    },
    "requires_arc": true,
    "source_files": "SwiftyVersionTracker/*",
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This