onDisappear not called when closing a document on macOS (Designed for iPad), works on iPad

When running a SwiftUI DocumentGroup app on macOS designed for iPad, onDisappear is not called when closing a document, and deinit of state objects owned by a ContentView is not invoked. This behavior works as expected on iPad.

@main
struct MyApp: App {
    var body: some Scene {
        DocumentGroup(newDocument: MyDocument()) { file in
            ContentView(document: file.$document)
                  .onDisappear {
                      print("This isn't called on macOS Designed For iPad, but is on iPad when closing a document.")
                  }
        }
    }
}

It is my understanding that for a macOS designed for iPad these lifecycle events would behave the same - otherwise there appears to be no way to detect if a document has closed on macOS.

Thanks for reporting this in the forums, I believe you have also submitted a FB bug to us? FB22347979 Is that one yours? Just need to confirm is the same person. Thanks

Albert 
  Worldwide Developer Relations.

onDisappear not called when closing a document on macOS (Designed for iPad), works on iPad
 
 
Q