Swiftpack.co - Package - johnfairh/TMLPersistentContainer

TMLPersistentContainer

CI codecov Pod Carthage compatible Platforms License

Automatic shortest-path multi-step Core Data migrations in Swift.

logo

A Swift extension to Core Data's NSPersistentContainer that automatically detects and performs multi-step store migration using the shortest valid sequence of migrations. The library supports both light-weight and heavy-weight migrations, multiple stores, progress reporting, and configurable logging.

Example

Minimally replace the call to NSPersistentContainer.init:

container = PersistentContainer(name: "MyStore",
                                managedObjectModel: model)

Additional parameters optionally enable more features:

container = PersistentContainer(name: "MyStore",
                                managedObjectModel: model,
                                bundles: [Bundle.main, myResBundle],
                                modelVersionOrder: .list("V_One", "V_Two", "V_Six"),
                                logMessageHandler: myLogHandler)
container.migrationDelegate = self

All migrations happen as part of NSPersistentContainer.loadPersistentStores.

Documentation

Requirements

Swift 4.1, Xcode 9.3.1

  • See the swift31 branch for a Swift 31 version.
  • See the swift4 branch for a Swift 4 version.

The library is based on NSPersistentContainer so requires a minimum deployment target of iOS 10.0, macOS 10.12, tvOS 10.0, or watchOS 3.0.

No additional software dependencies.

Installation

CocoaPods:

pod 'TMLPersistentContainer'

Swift package manager:

.Package(url: "https://github.com/johnfairh/TMLPersistentContainer/", majorVersion: 3)

Carthage:

github "johnfairh/TMLPersistentContainer"

Contributions

Contributions and feedback welcome: open an issue / johnfairh@gmail.com / twitter @johnfairh

License

Distributed under the ISC license.

Github

link
Stars: 5
Help us keep the lights on

Dependencies

Used By

Total:

Releases

3.0.0 - May 21, 2018

Breaking

2.0.0 - Oct 23, 2017

Breaking
Enhancements
  • None.
Bug Fixes
  • None.

1.0.1 - Sep 24, 2017

Breaking
  • None.
Enhancements
  • None.
Bug Fixes
  • Detect best migration path correctly when first step of two alternates is an explicit migration. John Fairhurst #5