Post

Replies

Boosts

Views

Activity

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.
1
0
16
7h
UIDocument crashes when overriding writeContents(_:) in Swift 6
I’ve been trying to set up a UIDocument and override writeContents(...). This works correctly in older projects, but I haven’t been able to get it working in my new iOS 26 app using Swift 6. To troubleshoot, I tested the Particles demo and successfully overrode writeContents there. However, as soon as I switch that project to iOS 26 and Swift 6, calling save; which triggers writeContents, causes the same crash. override public func writeContents( _ data: Any, to url: URL, for _: UIDocument.SaveOperation, originalContentsURL _: URL?, ) throws { ... } Thread 10 Queue : UIDocument File Access (serial)
Topic: UI Frameworks SubTopic: UIKit
1
0
93
Nov ’25
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.
Replies
1
Boosts
0
Views
16
Activity
7h
UIDocument crashes when overriding writeContents(_:) in Swift 6
I’ve been trying to set up a UIDocument and override writeContents(...). This works correctly in older projects, but I haven’t been able to get it working in my new iOS 26 app using Swift 6. To troubleshoot, I tested the Particles demo and successfully overrode writeContents there. However, as soon as I switch that project to iOS 26 and Swift 6, calling save; which triggers writeContents, causes the same crash. override public func writeContents( _ data: Any, to url: URL, for _: UIDocument.SaveOperation, originalContentsURL _: URL?, ) throws { ... } Thread 10 Queue : UIDocument File Access (serial)
Topic: UI Frameworks SubTopic: UIKit
Replies
1
Boosts
0
Views
93
Activity
Nov ’25