Swift UI DocumentGroup: write to FileWrapper and name document

How can I set a name for a new document which was just created after calling the write method from the FileDocument's protocol ?. I tried to use the properties from the FileWrapper class like '.filename':

Code Block
func write(to fileWrapper: inout FileWrapper, contentType: UTType) throws {
        let data = text.data(using: .utf8)!
        fileWrapper = FileWrapper(regularFileWithContents: data)
        //fileWrapper.filename = "newName"
         //fileWrapper.preferredFilename = "newName"
    }


I have the same issue, and studied various solutions. In my opinion 'preferredFilename' seems be the best, in theory. unfortunately currently even I didn't found a working solution.
In addition to writing, I haven't been successful in reading the filename or preferredFilename in a DocumentGroup
either...

Code Block
init(configuration: ReadConfiguration) throws {
let filename = configuration.file.filename
let preferredFilename = configuration.file.preferredFilename
[...]
}


...Here filename & preferredFilename always returns nil even if the the file has been named by the user before the document is opened.

(I am able to read and write the filenames of Child FileWappers, but the 'root' filewrapper's filename seems always inaccessible.)
Swift UI DocumentGroup: write to FileWrapper and name document
 
 
Q