Article

Identifying an App's Containers

Use Xcode's project navigator to find the identifiers of active CloudKit containers.

Overview

An app's Xcode project manages which CloudKit containers are available to that app. When you write code that needs to provide container identifiers for all of the containers your app uses, reference the list of active containers in Xcode.

Identify the Containers Your App Uses

In your app's Xcode project, select Capabilities > iCloud in the project navigator.

A screenshot showing a list of three enabled container identifiers in Xcode: MyExampleApp, documents, and settings.

Once you've identified the containers your app uses, you can initialize instances of CKContainer in your app to interact with CloudKit data.

// These constants correspond to the containers selected above.
let defaultContainer = CKContainer.default()
let documents = CKContainer(identifier: "iCloud.com.example.myexampleapp.documents")
let settings = CKContainer(identifier: "iCloud.com.example.myexampleapp.settings")

See Also

User Data Management

Providing User Access to CloudKit Data

Give users access to the data your app stores on their behalf.

Changing Access Controls on User Data

Restrict access to or lift restrictions on a user's data at their request.

Responding to Requests to Delete Data

Provide options for users to delete their CloudKit data from your app.