Search code examples
iosicloudicloud-drive

iOS ubiquitous file not uploaded to iCloud (simulator)


I'm trying to save arbitrary files from my application's sandbox to iCloud Drive, on the iOS 10.3 simulator.

iCloud Drive is enabled and I'm signed in. If I open the iCloud Drive app on the simulator, I see files in there.

So, in my app:

I obtain the container with:

[[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil]

Which gives me something like this:

file:///Users/me/Library/Developer/CoreSimulator/Devices/F873A728-0314-4666-A137-830FF6280F05/data/Library/Mobile%20Documents/iCloud~com~me~iclouduploadtest/

Then I make my sandboxed file ubiquitous, like this:

NSError *error;
if (![[NSFileManager defaultManager] setUbiquitous:YES itemAtURL:url destinationURL:ubiquityURL error:&error]) 
{
    NSLog(@"Error occurred: %@", error);
}

No error is reported, and if I look on disk I see the file disappear from url and appear inside the ubiquity container (the path obtained earlier).

Great! So my file is in iCloud! Or... not.

  • File is not visible in icloud.com, nor in iCloud Drive app on the simulator

  • NSMetadataQuery run on the simulator does not find the file in iCloud

  • Even after using Trigger iCloud sync in simulator debug menu

  • I try brctl log --wait --shorten and trigger the sync again. No errors are reported. Lots of starting sync down but nothing about syncing up, for any application.

Why isn't my file being uploaded to iCloud?

Am I doing something wrong, or missing a step?

Does iCloud Drive upload not work on the 10.3 simulator?


Solution

  • Sigh I uninstalled the app, disabled and re-enabled iCloud Drive, incremented the version and build numbers, and reinstalled the app. Now it works.