Error in Xcode 15, beta 8

I was using SwiftData to make a basic testing app, for the purpose of learning Swift. When I added in the @Relationship macro, I received this error: Type 'Schema.Relationship.Option' has no member 'cascade'. I do not understand the error 🤷🏻‍♂️. Can you help me out here? It would also be appreciated if you could give me a temporary fix. Thank you for your cooperation! 🤗 Here is the code:

import Foundation
import SwiftData

@Model
class TodoList {
    var title: String

    @Relationship(.cascade)
    var items: [TodoItem]
}


@Model
class TodoItem {
    let title: String
    var isDone: Bool
}
Answered by ebhamilton in 763922022

The API has changed since the WWDC videos. You need to add deleteRule: in front of cascade.

class TodoList {
    var title: String

    @Relationship(deleteRule: .cascade)
    var items: [TodoItem]
}

This Developer doc on Switching from Core Data has the current syntax (Beta 8) https://developer.apple.com/documentation/coredata/adopting_swiftdata_for_a_core_data_app

Accepted Answer

The API has changed since the WWDC videos. You need to add deleteRule: in front of cascade.

class TodoList {
    var title: String

    @Relationship(deleteRule: .cascade)
    var items: [TodoItem]
}

This Developer doc on Switching from Core Data has the current syntax (Beta 8) https://developer.apple.com/documentation/coredata/adopting_swiftdata_for_a_core_data_app

Thanks! It worked! 😄

Error in Xcode 15, beta 8
 
 
Q