XCode Beta 7 - Cannot convert value of type 'ModelConfiguration' to expected argument type 'any PersistentModel.Type'

In XCode Beta 7 I am getting a new error: Cannot convert value of type 'ModelConfiguration' to expected argument type 'any PersistentModel.Type'

struct AppleClosetApp: App {
let config = ModelConfiguration(url: AppGroup.facts.containerURL ?? URL(fileURLWithPath: ""))
var body: some Scene {
WindowGroup {
ClosetNavigationView()
.modelContainer(try! ModelContainer(for: Closet.self,
config))
}
}
}

Anyone else saving to a custom swift data URL getting this emergent issue?

Answered by spudnik187 in 762584022

The signatures for the ModelContainer convenience initializers have changed to take the configuration as a named parameter. This should do the trick:

struct AppleClosetApp: App {
let config = ModelConfiguration(url: AppGroup.facts.containerURL ?? URL(fileURLWithPath: ""))
var body: some Scene {
WindowGroup {
ClosetNavigationView()
.modelContainer(try! ModelContainer(for: Closet.self,
configurations: config))
}
}
}

I had to explicitly put in function parameter for ModelContainer.

So change:

.modelContainer(try! ModelContainer(for: Closet.self,
config))

to:

.modelContainer(try! ModelContainer(for: Closet.self,
configurations: config))
Accepted Answer

The signatures for the ModelContainer convenience initializers have changed to take the configuration as a named parameter. This should do the trick:

struct AppleClosetApp: App {
let config = ModelConfiguration(url: AppGroup.facts.containerURL ?? URL(fileURLWithPath: ""))
var body: some Scene {
WindowGroup {
ClosetNavigationView()
.modelContainer(try! ModelContainer(for: Closet.self,
configurations: config))
}
}
}
XCode Beta 7 - Cannot convert value of type 'ModelConfiguration' to expected argument type 'any PersistentModel.Type'
 
 
Q