Jean-Se
Jean-Se

Reputation: 23

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

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.

Upvotes: 2

Views: 1112

Answers (2)

Steven A.
Steven A.

Reputation: 11

Try importing SwiftUI in your file:

import SwiftUI

Upvotes: 1

lorem ipsum
lorem ipsum

Reputation: 29383

Change

var body: some Scene {

To

var body: some SwiftUI.Scene {

Upvotes: 3

Related Questions