I also had this error within an SPM target. I solved this by switching my scheme to the package that holds the file I am trying to preview.
Topic:
Developer Tools & Services
SubTopic:
Xcode
Tags: