Reputation: 930
I'm trying to create a new XCode project, plain brand new and I can run it on the simulator, but on the canvas it says: Cannot preview in this file - active scheme does not build this file
If on top of that I start adding macOS support, it says:
'appName' is annotated with @main and must provide a main static function of type () -> Void or () throws -> Void.
It also says:
Cannot find type 'App' in scope
Cannot find type 'Scene' in scope
Regarding mac support I was reading there is a workaround, even though I tried and the error remains.
As for the active scheme, I read this, but doesn't help. I mean... there is only 1 scheme in a new project and it's selected automatically
I would assume a plain hello world project would work, what's going on?
Upvotes: 4
Views: 1835
Reputation: 930
Regarding the macOS support is what Asperi mentioned, on Catalina has problems supporting mac on XCode 12.
As for the new project failing, I found that if I press Cmd + Opt + P
, it would build it on the Canvas fine. I had tried clicking "Try again" on the canvas which I would assume is the same and didn't work. You don't need to delete the file and create a new one nor select any target since it's a new project and the target is selected automatically.
Also the @Main
doesn't have to be changed to run on iOS and iPad, for macOS support just wait until Big Sur releases.
Upvotes: 1
Reputation: 258277
SwiftUI 2.0 on macOS is available only starting from Big-Sur macOS 11.0
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public protocol App {
^^^^^^^^^^^^
Upvotes: 3