How would I manually create the Documents/ directory?
In C, mkdir(path, 0777).
In C++, create_directory(path).
In objC, [[NSFileManager defaultManager] createDirectoryAtURL: [NSURL urlWithFileSystemRepresentation: path] withIntermediateDirectories: false attributes: @[Some@[Extra]VerboSity]here] error: everyonejustpassesnil_becausewe'vegivenup_bythispoint_butReallyWeShouldDoSomethingToHandleErrors]
In Swift, same as objC but with different punctuation.
I'm not sure if this is necessary. What does seem to be the case is that if you haven't done anything then the empty directory is not visible in e.g. the Files app. I don't know if this is because the Documents directory doesn't exist, or because it is empty and empty directories are somehow hidden. Quite a few apps put a "readme" file in their iCloud Documents directory to make it appear. That is what I have done, using an NSFileManager method called something like copyFileFromHere: toThere: creatingIntermediateDirectoriesIfNecessary: true. So that would create Documents/ if necessary.
I don't know what a coordinated write block is
You need to look at the documentation for NSFilePresenter, NSFileCoordinator, and UIDocument. These are required for iCloud files, and also for local files if they are accessible from other apps, including the Files app.
Basically if you're going to read from a file, you need to do a "coordinated read" so that e.g. an instance of your app on another device or the Files app on the same device are told to save the file first. Coordinated writes are the converse. UIDocument simplifies a lot of this. But one important feature of these coordinated things is that they give you a potentially different path to access, in place of the path that you think you want to use. The point is that if there are conflicts between different devices you can have multiple versions of each file.
Having said all that - I don't think it would explain fopen(w) returning "no such file or directory".
It there a particular naming convention for the container name?
I would suggest reverse-dns i.e. com.your-business-name.your-app-name.this-container-name.