Tips · No.26

CloudKit Debugging: How to View Data for Test Accounts

Data missing in CloudKit Console during testing? Learn how to use the 'Act As iCloud Account' feature to inspect private databases for your test users and Sandbox accounts.

Published
Reading
1 min read
Tags
CloudKit
Language
English /阅读中文 →
Contents3 sections
  1. The Problem
  2. The Root Cause
  3. The Solution

TL;DR: The CloudKit Console defaults to showing data only for your developer account. To inspect data generated by a “personal account” or a “Sandbox test user” on a real device, you must switch contexts by clicking the “Act As iCloud Account” button.

The Problem

Many developers encounter a classic source of confusion when building cloud sync features with Core Data or SwiftData:

You successfully write data using a test account (or your personal daily driver) on a real device, and the sync status looks fine, yet when you query records in the CloudKit Dashboard (Console), it comes up empty.

The Root Cause

This is due to CloudKit’s strict privacy isolation mechanisms:

  1. Identity Mismatch: The CloudKit Console logs in with your Apple Developer ID by default.
  2. Data Isolation: Data in the Private Database is strictly segregated. The developer account can only see its own data; it cannot directly view data generated by other iCloud accounts (including your own non-developer test accounts).

The Solution

The CloudKit Console provides a feature called “Act As iCloud Account”, allowing developers to “impersonate” another iCloud user within the console session to inspect their private data.

Steps

  1. Log in to the CloudKit Console.

  2. Enter your App’s container and click the “Act As iCloud Account” button in the left sidebar of the page.

    CloudKit Act As iCloud Account Button

  3. In the popup window, enter the iCloud email and password of the account you are using on your simulator or physical device.

    CloudKit Login Window

  4. Once logged in successfully, the results of Query Records will display the data belonging to that specific test account.

Important Notes

  • Session Volatility: This login state is temporary. If you refresh the page, switch Containers, change environments (Development/Production), or click “Stop Acting As…”, you will automatically be logged out of the test account and revert to your developer account.
  • Two-Factor Authentication: If the test account has Two-Factor Authentication (2FA) enabled, you will be required to enter the verification code just as you would for a standard login.

Comments