Search code examples

How to make SwiftUI Preview build the main target only without test targets?

I just want to run the SwiftUI preview of my code, however, it's also building my unit tests. They have some errors in so I don't want them to be built. They're not usually built when running my Xcode project, so why is SwiftUI building them? Is there anyway to turn this off?

After a clean build, I refresh the preview and the status bar shows this:

enter image description here

And this is the scheme configuration:

enter image description here


  • According to this Apple Dev Foums post reply from a "Frameworks Engineer", it's a known issue and there's no fix other than deleting your test targets (!).

    It's a relatively recent post (~1 month old as of now) so hopefully it'll be fixed soon.