Xcode Previews doesn't work when used in a package that imports other packages.

I keep getting a Xcode Previews error in Xcode 12 from a package that imports other packages. As soon as I remove the dependency I'm able to see the SwiftUI preview. I'm only able to use previews in packages that have no dependencies

The error I get is: "LoadingError: failed to load library at path...Library not loaded " then it point to the dependency that it could not load in the current package.

How can I access Xcode Previews from a package that depends on other packages?
Answered by Developer Tools Engineer in 622246022
Hi,

Sorry to hear you are having problems. We have a received a feedback tracking this same issue, and we are actively investigating it. So far no known workaround.

Change Build configuration from Release to Debug

Still see this on Xcode 15.3 with imports of a local package. After commenting out the dependencies (both in the View code and the #preview) and removing the #import the #preview starts working again. For now, my only alternative is to put the local package code into the main project. Hopefully a solution will be available before I use the package in another app.

Xcode Previews doesn't work when used in a package that imports other packages.
 
 
Q