SwiftUI Previews are broken for me when one of imported Swift Package has a conditional dependency to another platform.
Steps to reproduce:
- Create Xcode Project with 2 targets. One for macOS, another for iOS.
- 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])),
]),
]
- 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?