FileDocument, Transferable, and DocumentGroup

I'm having a hard time reconciling DocumentGroup with the new APIs using Transferable.

Setting up an app with DocumentGroup using a FileDocument type gives you undo/redo and file-specific app opening behavior out of the box (even though the navigation view implicitly present in DocumentGroup is a nightmare to work with).

Now with Transferable we're given the ability to set up representations to share, drag/drop, copy/paste, etc.

The point where these collide in a confusing way is in the .navigationDocument API., which sets up elements in the navigation bar to interact with a "document" that is Transferable.

This would be great to include in a DocumentGroup scene backed by a FileDocument, but FileDocument is not currently Transferable and furthermore the Navigation View underlying the DocumentGroup isn't easily exposed.

This really muddies the story around how to build document-based applications. Where does DocumentGroup fit in now that Transferable exists? Should I be providing my own conformance to Transferable on my FileDocument, reach down into the implicit NavigationView of DocumentGroup to get the new .navigationDocument functionality? Is DocumentGroup soon to be deprecated (or at least not for a more sophisticated use case) and apps should be built with Transferrable types in a normal WindowGroup that implements all of the other goodies that exist in DocumentGroup?

Any clarity around the intention with DocumentGroup and how such an app would fit into a world of Transferables would be greatly appreciated!

Replies

I'm not sure what to make of DocumentGroup. It seems like the way we're supposed to create a document-based SwiftUI app, but it's missing major pieces of functionality.

For example, there's no way to do state restoration. No way to run tests that create and open documents. No clear way to present first-run UI or let the user pick a document type to create.

Is everyone rolling their own alternative or how are people handling this?

  • I am no expert but might be worth filing a feedback as it is still in beta and post the feedback ID.

Add a Comment