Type 'MyApp' does not conform to protocol 'App'

70 views Asked by At

Newbie here learning Swift and tweaking a VisionOS app.

I am following Apple documentation to specify an initial window size. I have the following code in my ContentView.swift file:

@main
struct MyApp: App {
    var body: some Scene {
        WindowGroup {
            ContentView()
        }
        .defaultSize(CGSize(width: 600, height: 400))
    }
}

When I build the project, I get the following 2 errors:

  1. Type 'MyApp' does not conform to protocol 'App' (line 2)
  2. 'Scene' is ambiguous for type lookup in this context (line 3)

Any tips on how I can resolve these?

Thank you.

2

There are 2 answers

0
lorem ipsum On BEST ANSWER

Change

var body: some Scene {

To

var body: some SwiftUI.Scene {
0
Steven A. On

Try importing SwiftUI in your file:

import SwiftUI