FB9957111: SwiftUI fail to preview dependented Package PreviewProvider
- Date: 2022-03-15
- Resolution: Open
- Area: SwiftUI & Xcode
- OS: 12.3 (21E230)
- Type: Bug
- Keywords: Xcode
Description
Please describe the issue: Say I have package A and package B, both of them have some SwiftUI PreviewProvider. And A depends on B (A -> B). When opening Package A, I can preview B’s SwiftUI PreviewProvider as well. This is the expected behavior.
However, if there is a package C, and both A and B depend on C. Then when opening Package A, I can not preview B’s SwiftUI PreviewProvider. The diagnostics will tell me that the linker failed to link C.
I think there is some link-related logic issue on SwiftUI Preview.
Please list the steps you took to reproduce the issue: Making 3 simple Package: A B C Add simple SwiftUI preview in Package A and B Make A depends on B and C Make B depends on C Opening Package.swift in folder A. Go the package B to preview and fail.
What did you expect to happen? Package B previews normally.
What actually happened? Package B fails to preview.
A temp workaround is to disable the testTarget in the A Package.
See Minimum reproducible environment FolderTest.zip