I am developing a package of Swift Package Manager where SwiftUI views need to be included.
Every SwiftUI view should have a preview.
However, when I try to
Xcode 12
With Xcode 12 the SwiftUI Preview just works 'as-should' in standalone Package
Xcode 11+
Is it possible to run SwiftUI preview somehow directly from SPM Package without building the main target?
No, at least till now (Xcode 11.4beta3). Preview is a variant of Simulator and it needs UI executable to setup full-functional run-time context for your view preview.
Solution (from practice): setup SwiftUI executable target that in parallel contains all files from package (or package itself, depends) and perform all SwiftUI development it it, but package itself build during continuous integration process (including unit-testing).