I was original poster for this thread. After finding the problem still exists in beta 7 and discovered the issue is caused by defining a SwiftData model in a Package. The compilation error occurs when the model package is imported into a different package, including unit test.
@qmay provided this confirmation, with an awkward workaround.
Check this GitHub issue — qmay 2 days ago
I submitted a Feedback FB13034576 including sample to reproduce.
I also confirmed that copying the exact swift file directly into an app project will compile and run without error. For now, I've been forced to abandon package modularity and copy may SwiftData code directly into my app project.
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags: