Reputation: 17329
In my project, I use multiple SPM to split up my app into smaller chunks/modules. This works perfect, including SwiftUI previews which can include views from other modules as well.
Unless there are Image
s involved; then the preview agent crashes. I created a small Pot showing this... https://github.com/arkulpa/SPMAssetPOC
Images are shown correctly as long as the preview only contains views with assets from the current SPM, but as soon as there's a view (including an asset) from another SPM, the PreviewAgent crashes...
Upvotes: 1
Views: 1879
Reputation: 711
This is definitely a bug. The issue is related to loading bundle resources transitively.
"This is a known issue when using resources of transitive dependencies while previewing a standalone package. Using an app as the preview host as you are doing is the recommended workaround at the moment."
See the Swift forums here for more details: https://forums.swift.org/t/xcode-previews-swiftpm-resources-xcpreviewagent-crashed/51680
Upvotes: 1