Does SwiftData not allow model class inheritance?

Just for grins, I tried running the SwiftData generation tool on the existing Core Data model of a non-trivial app I've worked on for a decade or so. It's pretty substantial, and uses some more advanced features, so it seemed like an interesting test case.

One of the warnings that was not reported by the UI, but which showed up in the generated code was quite a few instances of this:

Entity inheritance on entity Bar (parent class Foo) is unsupported in SwiftData.

Now that I'm looking at the code examples more carefully, I see an awful lot of final class, which maybe should have raised a red flag sooner. But to the best of my recollection, none of the sessions outright said that inheritance (was or) was not supported. Core Data has supported this functionality for a long time (maybe since the beginning).

Assuming that this isn't supported in this first seed, are there plans to provide this functionality in the future? By the launch of iOS 17?

(For the record, this model has 93 entities, of which 34 have parent entities. 14 are abstract, which I gather is also not supported. 3 of the entities are both abstract and have parent entities.)

Post not yet marked as solved Up vote post of 610 Down vote post of 610
785 views

Replies

I tried out Swift Data and thought: "Surely I'm missing something", because the only way I was able to make inheritance 'work' was by casting to the base/parent class when I wanted to save in the database, and casting to the child class when I wanted to display it, which oddly enough, somehow works, and it somehow saves fields that aren't present on the parent class, but are present on the child class. How or why is beyond me, but yea I'm hoping they add inheritance sometime soon, I'm not even sure why they would release swift data without support for inheritance.