A am working with UIDocuments and iCloud. I am successfully able to write out a file to iCloud but not seeing in on the device and the files app.
I have the following in info.plist.
<key>NSUbiquitousContainers</key>
<dict>
<key>iCloud.myAppName</key>
<dict>
<key>NSUbiquitousContainerIsDocumentScopePublic</key>
<true/>
<key>NSUbiquitousContainerName</key>
<string>myAppName</string>
<key>NSUbiquitousContainerSupportedFolderLevels</key>
<string>Any</string>
</dict>
</dict>
Inside my code I can create the directory and then write the file.
var containerUrl: URL? {
return FileManager.default.url(forUbiquityContainerIdentifier: nil)?.appendingPathComponent("myAppName")
}
let url = containerUrl?.appendingPathComponent("fileName.fileType")
print("url: \(url)")
The print returns:
file:///private/var/mobile/Library/Mobile%20Documents/iCloud~myAppName/myAppName/fileName.fileType
I can test and see that the files are written out with code such as:
let boolTest: Bool = !FileManager.default.fileExists(atPath: testUrl!.path, isDirectory: nil)
print("!file exist: \(boolTest)")
In the "Signing & Capabilities" tab of my Target under iCloud I have clicked "iCloud Documents" and have a container called iCloud.myAppName that is assigned to my Team. (Note: There are two other checks "Key-value storage" and "CloudKit". I have tried those both ways. I believe they should be unchecked.)
Regardless, all seems to work well. I can see through the fileExist that it is written. However, I cannot see the documents in the File app or pull up the documents through the app. Only the documents on the device.
At this point, I am not sure what I am missing. Nor do I have any ideas as to how to debug this.