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?
Issue still present on Xcode15 beta 7, and honestly this prevents the creations of connected chains of swiftui packages, to modularize your UI code...
Bump because sadly this is still an issue
Xcode 15.0.1, issue still persists, Completely beating the purpose of breaking your code into modules. @Developer Tools Engineer Please, do something!
I too am facing this issue, interestingly it's happening on my AnnouncementModule
package, not necessarily on a preview of a package, of a package. I've been doing some serious DEEP diving into this issue, and if I manage to find a solution, I'll share back here. My gut says this isn't an "Apple" issue, but more of a "Dev" issue and not understanding some really obscure technical thing.
The image here shows how my dependency tree looks in a reproducible example. I am able to get previews working just fine for Design
which is incredibly odd, given it's a dependency for AnnouncementModule
.
I think the issue isn't that all package imports break Xcode Previews. I am currently building a Swift Package where I use SwiftUI previews. I am integrating 2 packages simultaneously into this target and integrating the first one was a breeze. As soon as I introduced the second one, my preview crashes and I am getting an error:
I think the issue here is that some trait of that second Package causes Previews to break. For this second package, there are some setup steps that I cannot take in a Swift Package like Info.plist entries. It would be great if Xcode or the Xcode preview failure error would give an exact reason why this second package was unable to be loaded.
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.