I'm trying to implement multiple window support for my app, but the system restores the wrong scene when the app is relaunched. Here's my code:
import SwiftUI
@main
struct TestApp: App {
@Environment(\.openWindow) private var openWindow
var body: some Scene {
WindowGroup(id: "Navigator") {
Button {
openWindow(id: "Editor", value: "test")
} label: {
Text("Open Window")
}
}
WindowGroup(id: "Editor", for: String.self) { id in
Text(id.wrappedValue ?? "none")
}
}
}
If I run the app and tap the button, the Editor window opens. If I force quit and open the app again, the app still has two windows open but both are Navigator windows.
I've tried adding handlesExternalEvents
to the Scene and advertising an activity with .userActivity(isActive:)
, neither changes this behaviour. Any advice?