SwiftUI Preview incorrectly tries to build conditional dependency from another platform.

SwiftUI Previews are broken for me when one of imported Swift Package has a conditional dependency to another platform.

Steps to reproduce:

  1. Create Xcode Project with 2 targets. One for macOS, another for iOS.
  2. Add a Swift Package that has a conditional dependency - eg. depends on another package but only on iOS.

Example:

targets: [
   .target(name: "Components",
           dependencies: [
           .productItem(name: "FloatingPanel", package: "FloatingPanel", condition: .when(platforms: [.iOS])),
      ]),
]
  1. Try running SwiftUI preview on macOS. It won’t work.

The error I get is no such module UIKit. It looks like Xcode is trying to build FloatingPanel dependency even though it's condition specifies iOS platform.

Is there any way to fix this?

Got same thing. Any ideas?

I'm getting the same thing as well.

SwiftUI Preview incorrectly tries to build conditional dependency from another platform.
 
 
Q