iOS 应用不会使用自定义 iCloud 容器
iOS App Won't use custom iCloud container
所以,我正在开发两个应用程序,我想使用同一个 iCloud 容器。
我已按照 Xcode 和苹果在线文档中所示的所有步骤进行操作。我在我的应用程序中添加了激活的 iCloud 功能,选中 CloudKit 复选框,选择了一个我想要使用的自定义容器(显然这两个应用程序是相同的)。
该应用更改了权利文件中的 iCloud 容器标识符,这应该表明一切正常。但是,每当我使用该应用程序并打印我的容器名称时,它都会显示每个应用程序的默认容器名称。
对于这两个应用程序,功能屏幕如下所示:
我创建了一个对象 CloudKitController
来管理所有云流量。我在应用程序启动时将其初始化,并设置如下变量:
var container: CKContainer
var publicDB: CKDatabase
let privateDB: CKDatabase
var delegate: CloudKitControllerDelegate?
override init() {
container = CKContainer.default()
print(container.containerIdentifier)
//this prints the name of the default container for the project
publicDB = container.publicCloudDatabase
privateDB = container.privateCloudDatabase
}
我什至去了开发者门户并确保我要使用的容器是两个应用程序关联的唯一容器。也没用。
我的问题是:如何让两个应用程序(显然来自同一个开发者帐户和配置文件)在一个 iCloud 容器上运行?
您声明您希望使用具有特定标识符的特定容器。但是您拥有的代码专门访问应用程序的默认容器。这不是你想要的。
变化:
container = CKContainer.default()
至:
container = CKContainer(identifier: "your shared container id")
有关详细信息,请阅读 CKContainer
class 的文档。
所以,我正在开发两个应用程序,我想使用同一个 iCloud 容器。
我已按照 Xcode 和苹果在线文档中所示的所有步骤进行操作。我在我的应用程序中添加了激活的 iCloud 功能,选中 CloudKit 复选框,选择了一个我想要使用的自定义容器(显然这两个应用程序是相同的)。
该应用更改了权利文件中的 iCloud 容器标识符,这应该表明一切正常。但是,每当我使用该应用程序并打印我的容器名称时,它都会显示每个应用程序的默认容器名称。
对于这两个应用程序,功能屏幕如下所示:
我创建了一个对象 CloudKitController
来管理所有云流量。我在应用程序启动时将其初始化,并设置如下变量:
var container: CKContainer
var publicDB: CKDatabase
let privateDB: CKDatabase
var delegate: CloudKitControllerDelegate?
override init() {
container = CKContainer.default()
print(container.containerIdentifier)
//this prints the name of the default container for the project
publicDB = container.publicCloudDatabase
privateDB = container.privateCloudDatabase
}
我什至去了开发者门户并确保我要使用的容器是两个应用程序关联的唯一容器。也没用。
我的问题是:如何让两个应用程序(显然来自同一个开发者帐户和配置文件)在一个 iCloud 容器上运行?
您声明您希望使用具有特定标识符的特定容器。但是您拥有的代码专门访问应用程序的默认容器。这不是你想要的。
变化:
container = CKContainer.default()
至:
container = CKContainer(identifier: "your shared container id")
有关详细信息,请阅读 CKContainer
class 的文档。