Thanks for being a part of WWDC25!

How did we do? We’d love to know your thoughts on this year’s conference. Take the survey here

Access DocumentGroup container by external WindowGroup

Hi,

I am currently developing a document-based application for macOS and have encountered a challenge related to document container management. Specifically, I need to open a windowGroup that shares the same container as the one used in the DocumentGroup. However, my current approach of using a global shared model container has led to unintended behavior: any new document created is linked to existing ones, and changes made in one document are reflected across all documents.

To address this issue, I am looking for a solution that allows each newly created document to be individualized while still sharing the document container with all relevant WindowGroups that require access to the data it holds. I would greatly appreciate any insights or recommendations you might have on how to achieve this. Thank you for your time and assistance. Best regards,

Something like:

@main

 struct Todo: App {

     var body: some Scene {

         DocumentGroup(editing: Item.self, contentType: .item) {
                        ContentView()
           }

WindowGroup {
            UndockView()
                 .modelContainer(of documentGroup above)
            }

     }
 }
Access DocumentGroup container by external WindowGroup
 
 
Q