swift Swift - CloudKit - 向一个或多个应用添加或共享容器

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了swift Swift - CloudKit - 向一个或多个应用添加或共享容器相关的知识,希望对你有一定的参考价值。

See: https://developer.apple.com/library/content/documentation/DataManagement/Conceptual/CloudKitQuickStart/EnablingiCloudandConfiguringCloudKit/EnablingiCloudandConfiguringCloudKit.html#//apple_ref/doc/uid/TP40014987-CH2-SW1

01. Add Containers to an App

Select an existing container ID used by another app or create a new one.

To add a container to an app

A. In the Capabilities pane under the iCloud settings, select “Specify custom containers.”
When you previously selected the CloudKit service, Xcode created a default container ID for your 
app that matches the bundle ID. A checkmark appears next to the default container ID.

B. If necessary, click the Refresh button below the Containers table to download containers from 
your developer account that are used by other apps.

C. In the row of the container ID you want to add, select the checkbox.
Xcode updates the list of container IDs in the entitlements file.


02. Create Custom Containers

Alternatively, create a custom container shared by multiple apps.

To create a custom container

A. If "Use default container” is selected, select “Specify custom containers.”

B. Click the Add button (+) at the bottom of the table.

C. In the dialog that appears, enter an identifier for the container you want to add.

Warning: You can’t delete a container ID, so choose the container ID carefully.
A container ID begins with iCloud. followed by a string in reverse DNS notation.

D. Click OK.

Xcode adds the new container ID to the Xcode project entitlements file and to your developer account

If you want to share the new container ID with another app, add the container to the app, as described 
in Add Containers to an App.

03. Verify Your Steps

You can view all the container IDs for your team in the Capabilities pane in Xcode or
your developer account. In your developer account, you can also add containers and edit the 
name of containers.

To view container IDs in your developer account

Go to Certificates, Identifiers & Profiles and for Mac apps, choose OS X from the 
pop-up menu on the left.

Under Identifiers, select iCloud Containers.

Optionally, in the upper right corner, click the search button and enter text in the search field.




以上是关于swift Swift - CloudKit - 向一个或多个应用添加或共享容器的主要内容,如果未能解决你的问题,请参考以下文章

swift Swift - CloudKit - 获取用户ID

swift Swift - CloudKit - 推送通知

swift Swift - CloudKit共享

swift Swift - CloudKit - 维护本地缓存

swift Swift - CloudKit - 部署架构

swift Swift - CloudKit订阅 - 5