I have the exact same issue and just filed a report FB15146262. iOS 18 doesn't set the one-to-many relationship from the 'one' side, i.e. setting student.school = school will actually keep the relationship at nil and can't be saved into context. This is visible in the debugger error message: SwiftData.DefaultStore save failed with error: Error Domain=NSCocoaErrorDomain Code=1570 %{PROPERTY}@ is a required value. UserInfo={NSValidationErrorObject= (entity: Student; id: 0x600000223380 x-coredata://3B392729-2729-4812-B567-647032714A50/Student/t6F58A598-9DC2-4927-A418-8D37D760FC072; data: { name = jack; school = nil; }), NSLocalizedDescription=%{PROPERTY}@ is a required value., NSValidationErrorKey=school, NSValidationErrorValue=null} The workaround by @Rainbowql with additionally calling append fixes this issue on iOS 18 but causes the app to crash on iOS 17, because the relationship is already set normally before calling append. On iOS 17, you will get: SwiftData/PersistentModel.swift:540: Fatal error:
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags: