I have had the same problem with displaying previews in Swift packages.
My project architecture is: UIComponents (local package) - AppPackage (local package) - App
What I did was to add .dynamic parameter to .library declaration in both packages.
Now I can see previews for all SwiftUI files, both in UIComponents and AppPackage.
swift
products: [
.library(
name: "UIComponents",
type: .dynamic, /* added parameter */
targets: ["UIComponents"])
],
swift
products: [
.library(
name: "AppPackage",
type: .dynamic, /* added parameter */
targets: ["AppPackage"])
],
dependencies: [
.package(path: "../UIComponents")
],