Post not yet marked as solved
Post marked as unsolved with 3 replies, 1,653 views
I've been working for the past day or so to add a very minor feature to one of our UIKit based apps using SwiftUI, as an experiment. Suddenly, this morning, previews stopped working, citing a build error that only occurs when building for preview:
Compiling failed: 'main' attribute cannot be used in a module that contains top-level code
I was editing the view when this started happening, but no fiddling I've done with it since has fixed the issue.
I have tried:
Reverting all changes in Git
Cleaning the build folder (repeatedly)
Touching both the file with the SwiftUI view, and the AppDelegate that's annotated with @main
Closing the project, and Xcode
The project builds and runs just fine: this error only occurs with previews.
I had been working in Xcode 12.5 beta 2 when the problem started, but it persists when I open the project in Xcode 12.3.
Is there some extra build cache that I can go purge?