Ios 使用同一ubiquity容器在多个应用程序上存储iCloud键值

Ios 使用同一ubiquity容器在多个应用程序上存储iCloud键值,ios,macos,icloud-api,nsubiquitouskeyvaluestore,Ios,Macos,Icloud Api,Nsubiquitouskeyvaluestore,我知道以前也有人以类似的方式提出过这类问题,但没有找到令人满意的答案。请找个人解释一下好吗。在开始我的问题之前,我想补充一点,应用程序ID已启用iCloud,并且在此之后将创建/下载/安装临时配置文件 我在这里遵循了苹果的文档 我有一个MAC应用程序和一个iOS应用程序。在MAC应用程序的“功能”部分,iCloud已打开。Ubiquity容器包含我的MAC应用程序的捆绑包标识符。我检查了.authentication文件,iCloud键值存储为TeamIdentifier.bundleident

我知道以前也有人以类似的方式提出过这类问题,但没有找到令人满意的答案。请找个人解释一下好吗。在开始我的问题之前,我想补充一点,应用程序ID已启用iCloud,并且在此之后将创建/下载/安装临时配置文件

我在这里遵循了苹果的文档

我有一个MAC应用程序和一个iOS应用程序。在MAC应用程序的“功能”部分,iCloud已打开。Ubiquity容器包含我的MAC应用程序的捆绑包标识符。我检查了.authentication文件,iCloud键值存储为TeamIdentifier.bundleidentifier。一切正常。值存储在iCloud中,我可以毫无问题地获取它们

现在在我的iOS应用程序上。在功能部分,我打开了iCloud,并将ubiquity容器字符串设置为我的MAC应用程序的捆绑标识符。选中。授权文件和iCloud键值存储字符串设置为TeamIdentifier.bundleidentifier。从iCloud获取数据时,我的iOS应用程序的值为零。我已经在模拟器和iPhone5上进行了测试,但没有成功


非常感谢您的帮助。

您有没有找到解决方案?当您说值设置为
TeamIdentifier.bundleidentifier
时,这是否只是您的团队ID和Mac应用程序捆绑标识符的占位符?或者是权利文件
$(TeamIdentifierPrefix)$(CbundleIdentifier)
中的值?
Configuring a Common Ubiquity Container for Multiple Apps
In the Xcode target editor’s Summary tab, you can request access to as many ubiquity containers as you need for your app. For example, say you provide a free and paid version of your app. You’d want users, who upgrade, to retain access to their iCloud documents. Or, perhaps you provide two apps that interoperate and need access to each other’s files. In both of these examples, you obtain the needed access by specifying a common ubiquity container and then requesting access to it from each app.

To configure a common ubiquity container
Pick one of your iCloud-enabled apps to serve as the primary app for the common ubiquity container.

The app you pick can be the current one you are developing, or another app of yours submitted for distribution in the App Store and whose entitlements use the same team ID.

In the first row of the Xcode target editor’s iCloud Containers list, enter the bundle identifier of your primary iCloud-enabled app.

If you then look in the .entitlements property list file, you’ll see that Xcode has automatically qualified the identifier string by prefixing it with your team ID.

To retrieve a URL for a ubiquity container, you must pass the fully qualified string to the NSFileManager method URLForUbiquityContainerIdentifier:. That is, you must pass the complete container identifier string, which includes your team ID, that you see in the .entitlements property list file. You can pass nil to this method to retrieve the URL for the first container in the list.

For more information about how to configure entitlements, see “Configuring Store Technologies in Xcode and iTunes Connect” in App Distribution Guide