reports icon indicating copy to clipboard operation
reports copied to clipboard

FB9957111: SwiftUI fail to preview dependented Package PreviewProvider

Open Kyle-Ye opened this issue 3 years ago • 1 comments

  • 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.

Kyle-Ye avatar Mar 14 '22 16:03 Kyle-Ye

A temp workaround is to disable the testTarget in the A Package.

See Minimum reproducible environment FolderTest.zip

Kyle-Ye avatar Mar 15 '22 03:03 Kyle-Ye