wip
This commit is contained in:
30
Workouts/Schema/AppContainer.swift
Normal file
30
Workouts/Schema/AppContainer.swift
Normal file
@ -0,0 +1,30 @@
|
||||
import Foundation
|
||||
import SwiftData
|
||||
|
||||
final class AppContainer {
|
||||
static let logger = AppLogger(
|
||||
subsystem: Bundle.main.bundleIdentifier ?? "dev.rzen.indie.Workouts",
|
||||
category: "AppContainer"
|
||||
)
|
||||
|
||||
static func create() -> ModelContainer {
|
||||
// Using the current models directly without migration plan to avoid reference errors
|
||||
let schema = Schema(SchemaVersion.models)
|
||||
let configuration = ModelConfiguration(cloudKitDatabase: .automatic)
|
||||
let container = try! ModelContainer(for: schema, configurations: configuration)
|
||||
return container
|
||||
}
|
||||
|
||||
@MainActor
|
||||
static var preview: ModelContainer {
|
||||
let configuration = ModelConfiguration(isStoredInMemoryOnly: true)
|
||||
|
||||
do {
|
||||
let schema = Schema(SchemaVersion.models)
|
||||
let container = try ModelContainer(for: schema, configurations: configuration)
|
||||
return container
|
||||
} catch {
|
||||
fatalError("Failed to create preview ModelContainer: \(error.localizedDescription)")
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user