I can't find the method to create ModelContainer
that appears in the video at 8: 52.
The code in the video is as follows:
let container = ModelContainer(
for: Trip.self,
migrationPlan: SampleTripsMigrationPlan.self
)
This method doesn't seem to exist in Xcode15.
I found other method to create ModelContainer using Schema and Schema MigrationPlan in Xcode15.
public convenience init(for givenSchema: Schema, migrationPlan: (SchemaMigrationPlan.Type)? = nil, _ configurations: ModelConfiguration...) throws
And I tried to create a Schema
to use this method, like this:
let container = try! ModelContainer(for: .init([Person.self]), migrationPlan: MigrationPlan.self)
But an error occurred during runtime
SwiftData/ModelContext.swift:177: Fatal error: Container does not have any data stores
How to create a ModelContainer with [PersistentModel]
and SchemaMigrationPlan
?
Xcode Version: 15.0 beta (15A5160n)
MacOS: 13.3.1 (a) (22E772610a)