Latest 0.2.0
Homepage https://github.com/radioboo/Migrator
License MIT
Platforms ios 8.0, requires ARC
Dependencies EDSemver
Authors

[![CI Status](http://img.shields.io/travis/SAKAI, Atsushi/Migrator.svg?style=flat)](https://travis-ci.org/SAKAI, Atsushi/Migrator)
Version
License
Platform

  • Migrator is a library for performing the migration of the data when the iOS app has been upgraded.
  • This library has implemented by Swift Language and inspired by MFMigrationManager.

Usage

To run the example project, clone the repo, and run pod install from the Example directory first.
And please read my test code, you can understand the more specific usage.

Basic

// Migrator Snippets
let migrator: Migrator = Migrator()
migrator.setInitialVersion("1.0.0") // Starting point you want to save the migration history
migrator.registerHandler("1.0.1") { () -> Void in
    print("[Migrator] Migration to v1.0.0....")
}
migrator.migrate()

Optional

Delegate Methods

You can implement delegate methods to get migration results.

let migrator: Migrator = Migrator()
migrator.delegate = self

func didSucceededMigration(migratedVersion: String) {
    print("[Migrator] Did Succeeded Migration to version (migratedVersion)!!")
}

func didFailedMigration(migratedVersion: String) {
    print("[Migrator] Did Failed Migration to version (migratedVersion)!!")
}

func didCompletedAllMigration() {
    print("[Migrator] Completed Migrations!!")
}

Error Handling

This library corresponds to Swift 2.0 Error Handling
The Swift Programming Language

// Define your custom ErrorType
enum MigrationError: ErrorType {
  case UnexpectedError
}

let migrator: Migrator = Migrator()
migrator.delegate = self // you can recognize to throw error from handler with delegate.
migrator.registerHandler("1.0.1") { () throws -> Void in
    print("[Migrator] Migration to v1.0.0....")
    throw MigrationError.UnexpectedError // Migration Closure will throw Error
}
migrator.migrate()

// will call below delegate method
func didFailedMigration(migratedVersion: String) {
    print("[Migrator] Did Failed Migration to version (migratedVersion)!!")
}

Installation

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

pod "Migrator"

Author

SAKAI, Atsushi, [email protected]

License

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

Latest podspec

{
    "name": "Migrator",
    "version": "0.2.0",
    "summary": "iOS Application Migration Handler",
    "description": "Migrator is a library for performing the migration of the data when the iOS app has been upgraded.",
    "homepage": "https://github.com/radioboo/Migrator",
    "license": "MIT",
    "authors": {
        "radioboo": "[email protected]"
    },
    "source": {
        "git": "https://github.com/radioboo/Migrator.git",
        "tag": "0.2.0"
    },
    "platforms": {
        "ios": "8.0"
    },
    "requires_arc": true,
    "source_files": "Pod/Classes/**/*",
    "resource_bundles": {
        "Migrator": [
            "Pod/Assets/*.png"
        ]
    },
    "dependencies": {
        "EDSemver": []
    }
}

Pin It on Pinterest

Share This