我知道以前曾以类似的方式提出过此类问题,但找不到令人满意的答案。有人可以解释一下吗。在我开始我的问题之前,我想补充一点,App ID 已启用 iCloud,并且在此之后会创建/下载/安装临时配置文件。
我在这里遵循了 Apple 文档https://developer.apple.com/library/mac/documentation/General/Conceptual/iCloudDesignGuide/Chapters/iCloudFundametals.html
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
我有一个 MAC 应用程序和一个 iOS 应用程序。在 MAC 应用程序的功能部分中,iCloud 已打开。Ubiquity 容器包含我的 MAC 应用程序的包标识符。我检查了 .entitlement 文件,iCloud 键值存储是 TeamIdentifier.bundleidentifier。一切正常。值存储在 iCloud 中,我可以毫无问题地获取它们。
现在在我的 iOS 应用程序上。在功能部分,我打开了 iCloud,并将普遍存在的容器字符串设置为我的 MAC 应用程序的捆绑标识符。检查的 .entitlement 文件和 iCloud 键值存储字符串设置为 TeamIdentifier.bundleidentifier。当我从 iCloud 获取时,我的 iOS 应用程序的值为零。我已经在模拟器和我的 iPhone 5 上测试过,但没有运气。
任何帮助是极大的赞赏。