SwiftUI Preview triggers test target build

The Build for Previews builds all my targets including the test targets. Is there a way to configure the relevant targets? I do not see an option in the schema editor, and disabling Find Implicit Dependencies has no effect either.

Post not yet marked as solved Up vote post of chkpnt Down vote post of chkpnt
3.1k views

Replies

Sorry to hear you are having problems getting the previews builds working as expected.

The issue you are hitting is a known issue that we hope to fix in a future update. There is no known workaround beyond temporarily removing the test targets.

  • I have two targets in my app with them having different versions of one library added to them. When trying to see the SwiftUI previews it tells me there is a "multiple commands produce ..." error. Does this then mean I have no chance of seeing the SwiftUI previews as long as I don't remove one of the targets or align their dependencies?

    Thanks for your help.

Add a Comment

It is still an issue in the Xcode 14.2 and is very annoying. More to that, the SwiftUI Previews build does not run Swift Package build plugins, making the test target build failing if it relies on those. One has to first build the target for testing to trigger the package plugins, then the previews start working.

This is still an issue in Xcode Version 15.0.1 (15A507). I created Feedback FB13283487. The Feedback includes a sample application that replicates the issue.

Still experiencing this in Xcode 15.2.0 (15C500b)

Still an issue in Xcode 15.3 (15E204a).

Still an issue in Xcode Version 15.3 (15E204a).

Experiencing this for the first time in Xcode 15.3. Is there a workaround? Why is this happening?