What is the expected way to use DocumentGroup to open and display directory content?

I want my app to open a folder and read (optionally edit) the files inside it. From the SwiftUI documentation it looks like DocumentGroup might be a good solution since I wouldn't need to manually handle the bookmarks / permissions.

How do I use DocumentGroup for this?

The following code crashes upon startup:

DocumentGroup(
   editing: CodeRepository.self, 
   contentType: .directory
) {
    Text("editor view")
}

To be clear this is to open an view any user selected folder. Not a folder with a custom file extension.

The initializer you are using requires the model type to conform to SwiftData.PersistentModel. A scene created using this initializer encapsulates all the storage-related work, and the storage is a SwiftData-backed package. See https://developer.apple.com/documentation/swiftui/documentgroup/init(editing:contenttype:editor:preparedocument:)-7uvjw

But even if you use another DocumentGroup initializer, you won't be able to access random folders. Both iOS and macOS operating systems define a document as a file or a package (directory with a file extension), not a folder.

To deal with a repository directory (or any other directory) the app needs to manage the file access directly.

What is the expected way to use DocumentGroup to open and display directory content?
 
 
Q