4

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?

TheNextman
  • 12,428
  • 2
  • 36
  • 75
  • 2
    Try follow the steps described in this answer http://stackoverflow.com/a/27358392/5031210, it helped me a lot when setting up iCloud Drive the first time. iCloud Drive does work on the simulator – Marco Boschi Apr 27 '17 at 17:13

1 Answers1

3

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

TheNextman
  • 12,428
  • 2
  • 36
  • 75
  • hey @thenextman, have you found what's the problem? Sometimes my app stops syncing and I have to disable and re-enable iCloud Drive to start working again. Do you know if there is some explanation for this to happen? – Tiago Pereira Aug 10 '17 at 17:03
  • Hi @Tiago Pereira, it sounds like a different problem. – TheNextman Aug 10 '17 at 17:13
  • I think they are quite similar. When I get this problem, the file is not visible in iCloud and I do not receive any information via NSMetadataQuery. And both of our problems are solved using the same approach by disable and re-enable iCloud Drive. – Tiago Pereira Aug 10 '17 at 17:18
  • Hmmm ok... Well I don't know more than what's above. It didn't work; I did the steps in my answer, and it works. Sorry I don't know the reason... – TheNextman Aug 10 '17 at 17:34