I'm not sure what version of Xcode you're running, but is it possible that you're running into this known issue from the beta?
Known Issues
Previewing view code in a SwiftData app results in a linker failure for the canvas despite that code compiling successfully for device and simulator. (111657477)
Workaround: Run your app in the simulator to test your UI instead of using Previews.
Source: Xcode beta release notes
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: