I am trying to accomplish the following:
- Read a .csv file from iCloud drive that was placed there using the Mac. This works using UIDocumentPickerViewController.
- Process the file in iOS - this works fine
- Create the documents directory for my App in iCloud drive such that it is visible from the Mac - NOT working
- Write/Save the processed file out to the UbiquityContainer such that it is visible on the Mac. - NOT working.
I have this set to create the documents directory.
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
if let iCloudDocumentsURL = FileManager.default.url(forUbiquityContainerIdentifier: nil)?.appendingPathComponent("Documents") {
if (!FileManager.default.fileExists(atPath: iCloudDocumentsURL.path, isDirectory: nil)) {
do {
try FileManager.default.createDirectory(at: iCloudDocumentsURL, withIntermediateDirectories: true, attributes: nil)
print("Created Directory at \(iCloudDocumentsURL)")
} catch {
print("Error Creating Directory: \(error)")
}
}
print("\(#function):\(#line) iCloudDocumentsURL =\n\(iCloudDocumentsURL)")
self.iCloudDocumentsURL = iCloudDocumentsURL
}
I have the entitlements turned on and a plist entry as follows:
<dict>
<key>iCloud.com.mycompany.SubLunch</key>
<dict>
<key>NSUbiquitousContainerIsDocumentScopePublic</key>
<true/>
<key>NSUbiquitousContainerName</key>
<string>SubLunch</string>
<key>NSUbiquitousContainerSupportedFolderLevels</key>
<string>One</string>
</dict>
I can see the file is getting written here:
file:///private/var/mobile/Library/Mobile%20Documents/iCloud~com~mycompany~SubLunch/Documents/LRA%20Order%20Detail%20Results.csv
But nothing changes on my iCloud Drive on my Mac.
I have used brctl log --wait --shorten
to view activity and I can see output.
What am I doing wrong here?
Thanks in advance