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.

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.

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?

When I try to build the preview, if there are any test targets in the project that the view file belongs to, it builds them all. I just checked.

SwiftUI Preview triggers test target build
 
 
Q