2

I'm trying to open two windows on App startup. One to show on another screen and the second to control the first window on my screen. Unfortunately I cannot get it running. I just tried to add a second WindowGroup, but it always just launches my first WindowGroup. I just read that this is the normal behaviour, but what is the correct way to open up two different windows on App startup?

import SwiftUI

@main
struct MyApp: App {
    
    var body: some Scene {
        WindowGroup("Test") {
            Text("Hello test")
                .frame(width: 1000, height: 1000, alignment: .center
                )
        }
        
        WindowGroup {
            ContentView()
                .frame(minWidth: 800, minHeight: 1000)
        }
    }
}
Cheolhyun
  • 169
  • 1
  • 7
pipo92
  • 119
  • 10

1 Answers1

0

I found the solution myself with help of this answer

Instead of putting the openURL part into a Button, just add it to the onAppear call of the ContentView.

pipo92
  • 119
  • 10