Automatic shortest-path multi-step Core Data migrations in Swift.
A set of Swift extensions to Core Data's NSPersistentContainer
and
NSPersistentCloudKitContainer
that automatically detect and perform
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.
Minimally replace the call to NSPersistentContainer.init
or
NSPersistentCloudKitContainer
:
container = PersistentCloudKitContainer(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
.
TestSimpleMigrate.testCanMigrateV1toV3inTwoSteps
for an end-to-end
example.Swift 5 or later, Xcode 10.2 or later.
The library is based on NSPersistentContainer
. The minimum deployment targets
are iOS 12.0, macOS 10.14.6, tvOS 12.0, and watchOS 3.0.
The PersistentCloudKitContainer
class is based on
NSPersistentCloudKitContainer
so further requires a minimum deployment target
of iOS 13.0, macOS 10.15, tvOS 13.0, or watchOS 6.0.`
No additional software dependencies.
CocoaPods:
pod 'TMLPersistentContainer'
Swift package manager:
.Package(url: "https://github.com/johnfairh/TMLPersistentContainer/", majorVersion: 5)
Carthage:
github "johnfairh/TMLPersistentContainer"
Contributions and feedback welcome: open an issue / [email protected] / @[email protected]
Distributed under the ISC license.
link |
Stars: 15 |
Last commit: 7 weeks ago |
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics