阅读背景:

保存CloudKit记录“未经过身份验证”(9/1002)“”此请求需要经过身份验证的帐户“”

来源:互联网 

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

在模拟器中保存CKRecord会出现以下错误:

                [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?

但是,它适用于手机。为什么模拟器无法访问CloudKit数据库?

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?

编辑:我认为通过将iCloud帐户添加到模拟器中我会很聪明 - 但iCloud呻吟说“这个设备”(模拟器)上不允许这样做。想法有人吗?

6 个解决方案

#1


27  

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

我遇到了同样的问题,我可以通过在模拟器中登录我的iCloud帐户来解决(设置> iCloud)。

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

从最新的Xcode开始,您可以在模拟器中登录您的iCloud帐户,一切都应该有效。

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.

如果您在登录时遇到问题,请尝试在桌面上访问iCloud.com并首先登录。一旦设置正确,然后尝试在模拟器中。

#2


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

#3


2  

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. 运行模拟器(Xcode) - 通过选择Product> Run,在模拟器中运行Xcode中的应用程序

  3. App Home Screen (Simulator) - Within the simulator, navigate to the Home screen by selecting Hardware > Home
  4. 应用程序主屏幕(模拟器) - 在模拟器中,通过选择硬件>主页导航到主屏幕

  5. Settings App (Simulator) - Find the settings app (gear), run it and select iCloud
  6. 设置应用程序(模拟器) - 找到设置应用程序(齿轮),运行它并选择iCloud

  7. 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
  8. 验证(模拟器) - 输入您的凭据并登录(如果您的凭据已更改,则重新登录)到iCloud。完成此操作后,您可以重新运行您的应用程序,它应该正确地向iCloud进行身份验证

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

一旦你这样做,你就可以进行未来的构建和运行。

#4


1  

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

除非我登录iPad Retina iOS8.1.1上的Settings app / iCloud部分,否则我遇到了类似的问题

#5


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.

我在用户记录中添加了一个id查询索引,当我删除此索引时,问题就停止了。

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

我甚至不知道这些事情之间的关系是什么,但它对我有用。

Sorry for the bad english

抱歉英语不好

#6


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.

完全重置模拟器(确保没有留下任何东西),重新安装它。也许你有一个错误的位版本?如果可能,请尝试在其他PC或笔记本电脑上运行。

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

我测试了它,我能够连接到iCloud,所以我很确定它的设置/错误安装等。


分享到: