The compiler is raising the following error for @Relationship(.cascade, inverse: ...)
with the message Type 'PropertyOptions' has no member 'cascade'
Is there a replacement for this property option, or is the cascade
behaviour implied internally by default?
Xcode 15 beta 5 missing cascade property option in @Relationship(.cascade) error.
My bad @availablemacOS >= 14
@MobileTen how did you solve this? I'm experiencing the same thing in Beta 6, and I don't have macOS as a build target at all. Only iOS 17. I still get the error about .cascade
not being a PropertyOptions member.
If i remove the .cascade
option i get this error instead: Variable 'self._$backingData' used before being initialized
. Project worked fine in Beta 5.
I managed to get my project to build, i had to change to things:
Change from: @Relationship(.cascade, inverse: \VesselLocation.anchorLocation)
to @Relationship(deleteRule: .cascade, inverse: \VesselLocation.anchorLocation)
Documentation of the new deleteRule: https://developer.apple.com/documentation/swiftdata/schema/relationship/deleterule-swift.enum
And i had to remove any default values from my model attributes. I had this:
@Model
final class Foo {
var bar: Bool = true
But that fails in Beta 6, but if you leave it empty it works:
@Model
final class Foo {
var bar: Bool
15 beta 6 has the same. I'm starting learning from some recent tutorials and hit the same error. @Relationship(.cascade) "Type 'PropertyOptions' has no member 'cascade'" Thanks!
For the cascade issue you can add deleteRule:
in front of it.
The issue regarding Variable 'self._$backingData' used before being initialized
is something different. You are right, removing the default value fixes the compile time error but breaks automatic CloudKit sync (FB12905731).
I had the same problem with the broken CloudKit sync. I solved it by changing code like var bar: Bool = true
to var bar: Bool!
. However, now you have to make sure that a value is set in the constructors. So not really the best solution from my point of view. But it seems to work at least.
It seems that you can make all of the variables optional where they are declared in the @Model class (eg var variable: String?), and then use nil coalescing to unwrap when the properties are called (?? ""), but then you get a compile time error when you call the parameter from @Bindable in the View using a binding. The below will not compile, even with the ?? "".
struct egView: View {
@Bindable var VM: ViewModel
var body: some View {
ButtonStruct(Variable: $VM.variable ?? "" )
}
Performing nil coalescing in the ButtonStruct doesnt seem to work either, so I am stumped.
The .cascade option is still missing in Beta 8 (target VisionOS)