Post

Replies

Boosts

Views

Activity

Reply to Unit testing SwiftData
In my unit tests, I need to insert Foo into a context before I can set the relationship to Bar. If the parent entity does not have a context I see a crash in the getter. let foo = Foo(bar: []) container.mainContext.insert(foo) foo.append(bar: Bar(value: 0)) You will need to mark the test as running on the MainActor to access the mainContext.
Topic: Programming Languages SubTopic: Swift Tags:
Jul ’23
Reply to Error in SwiftData migrationPlan execution
The only thing I see different to a migration I have working is that the versionIdentifier seems to have changed in Beta 5 to a non-optional string (the docs don't seem to have caught up). I've set them to a string of my choosing: static var versionIdentifier: String = "V1"
Topic: App & System Services SubTopic: iCloud Tags:
Replies
Boosts
Views
Activity
Jul ’23
Reply to Unit testing SwiftData
In my unit tests, I need to insert Foo into a context before I can set the relationship to Bar. If the parent entity does not have a context I see a crash in the getter. let foo = Foo(bar: []) container.mainContext.insert(foo) foo.append(bar: Bar(value: 0)) You will need to mark the test as running on the MainActor to access the mainContext.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jul ’23