EN VI

Swift - Type 'MyApp' does not conform to protocol 'App'?

2024-03-14 04:00:15
How to Swift - 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 {
Answer

Login


Forgot Your Password?

Create Account


Lost your password? Please enter your email address. You will receive a link to create a new password.

Reset Password

Back to login