iOS 上的 CloudKit + CoreData 和 watchOS 同步不起作用 [英] CloudKit + CoreData on iOS and watchOS sync not working

查看:28
本文介绍了iOS 上的 CloudKit + CoreData 和 watchOS 同步不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 iOS + watchOS 应用程序,我想使用相同的数据模型.因此,我创建了一个 CoreData 堆栈,并为 NSPersistentCloudKitContainer 设置了所有内容.

我的 iOS 应用程序可以访问 CloudKit 容器,因为我可以从控制台中的日志中读取,但是当我的 watchOS 应用程序想要连接到 CloudKit 容器时(与iOS 应用)我收到一条错误消息,指出容器的包 ID 无效.

我尝试了几个新容器.我还一次又一次地尝试检查功能窗格上的所有复选框.

我错过了什么吗?

(我还阅读了

还将类生成设置为 Cathegory/Extension 或 Manual,因为您需要为 iOS 和 WatchOS 的实体类实现稍有不同.如果有人知道如何使用一个类并检查哪个操作系统调用实例就完美了.

I have a iOS + watchOS app that I want to use the same data model. So I created a CoreData stack and I set up everything for NSPersistentCloudKitContainer.

My iOS app can access the CloudKit container as I can read from the logs in the console, however when my watchOS app wants to connect to the CloudKit container (same iCloud.foo.myID as the iOS app) I get an error saying Invalid bundle ID for container.

I tried several new containers. I also retried to check all checkboxes on the capabilities pane again and again.

Am I missing something?

(I also read Core data + CloudKit - sharing between iOS and watchOS companion app which did not help)

解决方案

I had same problem. Solution for me was make xcdatamodel shared for both app (in my case it's not standalone app for watch, but extension). So just check the box for share this model for both app:

Also set class generation to Cathegory/Extension or Manual, because you need a little bit different implementation of entity class for iOS and WatchOS. If someone know how to use one class and checking which OS call the instance it will be perfect.

这篇关于iOS 上的 CloudKit + CoreData 和 watchOS 同步不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆