20

Saving a CKRecord in the simulator gives me the following error:

[publicDatabase saveRecord:cloudRouteEntity completionHandler:^(CKRecord *record, NSError *error) {
    if (error) {
        NSLog(@"An error occured in %@: %@", NSStringFromSelector(_cmd), error);
        abort();
    } 
    else {
        dispatch_async(dispatch_get_main_queue(), ^(void) {
            //GUI
            NSLog(@"Created Cloudkit Entity");
        });
    }
}];

However, it works on the phone. Why does the simulator not have access to the CloudKit database?

EDIT: I thought I'd be clever by adding the iCloud account to the simulator - but iCloud moans that this is not allowed on "this device" (simulator). Ideas anyone?

ricardopereira
  • 11,118
  • 5
  • 63
  • 81
brainray
  • 12,512
  • 11
  • 67
  • 116
  • 1
    When you open the setting app in the simulator an go to iCloud, then you should be able to login with your apple account. Is that what you tried? If that doesn't work, try login in with a different account. – Edwin Vermeer Oct 11 '14 at 18:47
  • 2
    @Edwin Vermeer Yes, thats what I tried. The box says: "Device not supported - Your Apple ID is valid, but this iPhone is not qualified for iCloud". Did you get it to work? – brainray Oct 11 '14 at 21:37
  • Try resetting the simulator. I was able to login to iCloud on the simulator. – Edwin Vermeer Oct 16 '14 at 06:57

7 Answers7

35

I got the same problem, which I was able to resolve by logging in to my iCloud account in the simulator (Settings > iCloud).

As of the latest Xcode, you can log in to your iCloud account in the simulator, and everything should work.

If you are having trouble logging in, try to go to iCloud.com on a desktop and log in there first. Once that is set up properly, then try in the simulator.

Senseful
  • 86,719
  • 67
  • 308
  • 465
4

I'm seeing the same error. According to the discussion linked below the cause might be two-factor authentication.

https://discussions.apple.com/thread/6588883

Ronald Mannak
  • 446
  • 1
  • 4
  • 11
3

Because folks might misinterpret the approved answer (as I did) here is a little more detail to get through this (you can use keyboard shortcuts but I am specifying menu selections for clarity):

  1. Run simulator (Xcode) - Run an app from Xcode in the simulator by selecting Product > Run
  2. App Home Screen (Simulator) - Within the simulator, navigate to the Home screen by selecting Hardware > Home
  3. Settings App (Simulator) - Find the settings app (gear), run it and select iCloud
  4. Authenticate (Simulator) - Enter your credentials and login (or re-login if your credentials have changed) to iCloud. Once you do this you can re-run your app and it should properly authenticate to iCloud

Once you do this you are good to go for future builds and runs.

Wizkid
  • 1,015
  • 10
  • 10
1

Reset the simulator completely (make sure nothing is left), re-install it. Maybe you got a wrong bit version? If possible, try if it works on a other PC or Laptop.

I tested it and i was able to connect to iCloud so i am pretty sure its something about your settings / wrong install etc.

superarts.org
  • 7,009
  • 1
  • 58
  • 44
Etixpp
  • 320
  • 2
  • 11
1

I had similar issue unless I did login into Settings app/iCloud section on my iPad Retina iOS8.1.1

vedrano
  • 2,961
  • 1
  • 28
  • 25
1

I was having the same problem.

I has added an id query index in the Users Records, when i removed this index the problem stopped.

I dont even know whats the relation between these things, but it worked for me.

Sorry for the bad english

0

One of the users of my App had exactly the same issue but he was correctly logged in into iCloud and also had 2-factor authentication on. BUT, the switch for iCloud Drive was turned off in his iCloud settings and apparently this caused the issue!

I think this is strange because CloudKit doesn't use iCloud Drive per se and the switch for my App was on, but I guess somewhere down the line Apple suddenly demanded that iCloud Drive is on as well for CloudKit?

EDIT: This happened for 2 other users as well and for both again the solution was to turn on iCloud Drive!

Bob de Graaf
  • 2,630
  • 1
  • 25
  • 43