Search code examples
swiftrealitykitvisionos

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.


Solution

  • Change

    var body: some Scene {
    

    To

    var body: some SwiftUI.Scene {