Latest 1.0.0
Homepage https://github.com/zhengbomo/UpgradeManager
License MIT
Platforms ios 8.0, osx 10.9, watchos 2.0, tvos 9.0
Frameworks Foundation
Authors

版本升级框架

Feature

  1. 维护版本升级(如:数据库升级,数据迁移,数据初始化等)
  2. 跨版本升级(增量升级)

依赖

  1. 通过UserDefault保存当前版本,key=com.version.app.currentVersionKey

约定

  1. Version必须实现VersionProtocal协议,通过upgrade实现升级逻辑
  2. Version必须声明版本号
  3. 新版本号必须大于旧版本号
  4. 旧版本确定后不能改动
  5. 每个版本的版本号必须不一样,如果升级逻辑比较多,可以拆分成多个版本来升级
  6. VersionProtocol的版本号可以不与App的版本号一致

使用

Using Cocoapods

pod 'UpgradeManager', '~> 1.0'

Using Carthage

github "zhengbomo/UpgradeManager"
  1. 在应用启动(application:willFinishLaunchingWithOptions:)的时候执行
    
    // 版本号按从小到大顺序
    let versions: [VersionProtocol] = [
    InitVersion(),
    AddColumnVersion(),
    DataMigrationVersion()
    ]

// 设置版本号
UpgradeManager.shared.setVersion(versions: versions)

// 更新版本
UpgradeManager.shared.upgrade()

versions随着版本迭代逐渐增多

2. Version的定义
```swift
import UpgradeManager

class AddNameColumnVersion: VersionProtocol {
    var version: Int {
        // 新版本号必须大于旧版本号
        return 2
    }

    func upgrade() {
        DbService.addNameColumn()
    }
}

Latest podspec

{
    "name": "UpgradeManager",
    "version": "1.0.0",
    "summary": "data progress when upgrade app",
    "description": "data progress when upgrade app, like add column in database, data migration, data initialize",
    "homepage": "https://github.com/zhengbomo/UpgradeManager",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "bomo": "[email protected]"
    },
    "platforms": {
        "ios": "8.0",
        "osx": "10.9",
        "watchos": "2.0",
        "tvos": "9.0"
    },
    "source": {
        "git": "https://github.com/zhengbomo/UpgradeManager.git",
        "tag": "1.0.0"
    },
    "source_files": "Sources/**/*",
    "frameworks": "Foundation",
    "pushed_with_swift_version": "4.0"
}

Pin It on Pinterest

Share This