FileManager write permissions?

Trying to do something simple like write some files to iCloud without having to use the DocumentPicker.

Here’s a sample snippet:

let dirs = await
let ifm = FileManager.iCloud()
let file = dirs[0]


let filename = ifm.fileName(file, true)
let dirpath = file.replace(`\/${filename}$`, '')

let junkfile = ifm.joinPath(dirpath, 'junk.txt')
ifm.writeString(junkfile, 'hello')

When this runs, it just errors: Failed writing to disk.

The only place I can write without error is to the Scriptable Document Directory or Temporary Directory. Is there a way to save outside the Scriptable sandbox besides DocumentPicker.export(...)?

Take a look at bookmarked file paths in the File Manager docs.

Maybe I’m misunderstanding, but I’m not sure how a bookmark solves my desire to write a file outside of the Scriptable Files sandbox. I don’t want a bookmark to a file inside the current sandbox.

Here’s some highlights from the above.

Note that there is provision for bookmarking folders, not just files, and that this is the method for direct access to storage outside of Scriptable’s designated iCloud area.

Maybe this MacStories article will help put it in context?