SwiftUI previews fail with

As in the locked question here, I'm constantly running into this error:

Code Block
Compiling failed: 'main' attribute cannot be used in a module that contains top-level code


Once it starts, it's not clear how to stop it. No changes were made to my AppDelegate (It's a mostly-UIKit app that I'm adding some SwiftUI views to).

It compiles just fine with a regular build, but the SwiftUI preview can't build it. This is proving to be a real hindrance.

I can sometimes clear the condition by cleaning build and test results, and relaunching Xcode. But not always.

I filed FB9104575 and included the diagnostics.
SwiftUI previews fail with
 
 
Q