iCloud allows you to share user or app data among multiple instances of your app running on different devices. You can choose from three different iCloud services—key-value storage, document storage, and CloudKit—to add to your targets depending on how you want to store and retrieve data. Document storage and CloudKit use containers that you can share with apps developed by the same team.
Note: On macOS 10.11 and later, you can store documents in the user's iCloud Drive folder without needing to set the signing certificate and enable iCloud in the Xcode project. To configure iCloud Drive, read “Enabling Document Storage in iCloud Drive” in iCloud Design Guide.
In the project editor, add the iCloud capability to your target.
HomeKit appears in the Signing & Capabilities pane revealing the types of iCloud services you can use.
Key-value storage makes an app's preferences, configuration, or state (stored as key-value pairs) available on all user devices. The container ID for key-value storage is iCloud.[$(TeamIdentifierPrefix)].[$(CFBundleIdentifier)]
where the Team ID is a unique string assigned to your team.
To enable (or disable) key-value storage, click the “Key-value storage” checkbox.
Document storage makes an app's documents available on all user devices.
Important: Only the Account Holder or Admin role can configure iCloud document storage.
To enable (or disable) iCloud document storage, select the “iCloud Documents” checkbox.
If necessary, Xcode creates a default iCloud container for document storage that appears selected in the Containers table below. Document storage containers can be share with apps developed by the same team.
CloudKit stores structured app and user data in iCloud containers that can be shared by all users of an app.
The app owns the public database and can share it with all users of the app. Users own their private database and can share selected records with other users. Apps can use multiple containers and containers can be shared between different apps developed by the same team.
Important: Only the Account Holder or Admin role can configure CloudKit.
To enable CloudKit, select the CloudKit checkbox.
Xcode adds the CloudKit framework to your project.
To use multiple containers or share containers between apps, go to Manage iCloud document storage and CloudKit containers.
To manage your container data (create the schema and view records) during development, click CloudKit Dashboard.