JUST ENDED
|

iCloud & CloudKit Q&A

Connect with Apple engineers in the iCloud & CloudKit Q&A on the Apple Developer Forums.

Post

Replies

Boosts

Views

Activity

App Privacy Report says app connecting to Google for CKDatabase
I have a CloudKit container that I share across several apps. when I look at the App Privacy Report for these apps, it reflects the app connecting to Google storage APIs. While Apple might host with Google, the perception for users is iCloud and Apple. Can something be done about this? FB16410232 (CloudKit: CloudKit requests contacting google upload servers unexpectedly in app privacy report)
1
0
34
33m
CloudKit client usage should be attributed to app for MetricKit network metrics
In the past I ran into issues where the CloudKit client SDK was not attributing network usage in MetricKit. Since MetricKit got a major update this year I’d like to make sure usage goes here agains the app. I would expect transfer metrics to also count for CKSyncEngine, or the CloudKit config for core/swift data too. Is this assumption correct? FB12673917 (CloudKit / MetricKit: CloudKit queries are not counting towards network transfer metrics in MetricKit - WWDC23 lab, possible missing URLSession 'attributedBundleIdentifier' not being set)
1
0
33
50m
How can I reliably refresh WidgetKit widgets across devices after SwiftData + CloudKit synchronization?
Hey, I'm building an app that uses App Intents to modify data stored in SwiftData and synced through CloudKit. My expectation is that these changes should eventually be reflected in my app's widgets across all of the user's devices (iPhone, iPad, and Mac). However, I'm struggling to find a reliable way to ensure widgets reload when the underlying data changes as a result of a CloudKit sync. Reloading widgets on the device that modifies the data works reliably. The challenge is ensuring widgets reload on other devices after the updated data has been synced through CloudKit. In practice, this doesn't appear to happen reliably. I do not expect the user to manually open the app on those devices. I'm fine with the system launching my app in the background if that's part of the intended solution. Is there a recommended approach for keeping widgets in sync with SwiftData and CloudKit across devices? More specifically: Can WidgetKit be notified when SwiftData receives updates from CloudKit? Is there any supported way to trigger widget reloads on remote devices after a CloudKit sync? If not, what is the recommended architecture for ensuring widgets stay reasonably up to date when synchronized data changes? Things I've considered and/or tried: Calling sendChanges(_:) on CKSyncEngine from my App Intent to push changes immediately. However, this depends on an active Internet connection and doesn't address the case where changes are made offline and synchronized to CloudKit at a later time. Sending push notifications to the user's devices after an App Intent runs and using WidgetPushHandler to reload widgets. However, this requires confidence that the changes have already been uploaded to CloudKit. As far as I can tell, that's difficult or impossible to guarantee in the general case because of the issue described above. Calling fetchChanges(_:) on CKSyncEngine from the widget's timeline provider to ensure the widget has the latest data. However, the widget first needs some indication that new changes are available in CloudKit. Additionally, widget timeline reloads appear to have fairly strict execution time limits, which makes performing CloudKit synchronization work in that context seem less than ideal. My goal is for a Shortcut run on one device to update data and have widgets on all of the user's devices reflect those changes without requiring the user to manually open the app on each device. Am I thinking about this problem correctly, or is there a recommended pattern I'm missing? I'd appreciate any guidance on the intended WidgetKit + SwiftData + CloudKit integration story for this scenario. Thanks!
3
1
86
50m
Recommended way to display user-friendly iCloud Drive paths?
I’m building a macOS app that stores file URLs/bookmarks and displays file locations in the UI. For files in iCloud Drive, I want to show a user-friendly path such as: iCloud Drive / My Folder / File.jpg rather than an internal filesystem path. What is the recommended way to display iCloud Drive paths in a way that matches what users see in Finder? Thanks!
1
0
41
51m
Add Analytics Reports for CloudKit usage
I don’t have a feedback for this yet, but I’d like to see some analytics reports for CloudKit performance. Things to capture stats, performance, failures, etc. lots of the data in the console, but exposed through analytics reports. Related but different, if I had something like a generated OpenAPI client, I’d add instrumentation via client middleware. I could do most of what I’d want to instrument that way, status codes, timeouts, durations, payload sizes, etc. Alternatively, if the CloudKit client API exposed URLSession, or a hook to the delegate / metrics, a lot of what I am interested in could be achieved via session task metrics too. FB13628463 (CloudKit: Expose URLSessionTaskMetrics from CloudKit client)
1
0
25
1h
Display state of iCloud files
I’m building a macOS app that displays a large grid of image thumbnails similar to Photos. What is the recommended way to determine whether a file is locally available/downloaded without making a blocking call to the filesystem for every thumbnail? Thanks!
4
0
89
1h
CloudKit security roles
I’d like the ability to detect a users security role. This makes sense for detecting the roles assigned to named users for enabling workflows within an app. For example, user generated content and “moderators”. Instead of building an unlisted app, I’d prefer to just check permissions against the user. As a workaround, one could create record types with the same “security role” as the moderator actions, but to attempt to fetch a dummy record seems fragile and inefficient. FB9638492 (CloudKit: API to detect provided security role on current user)
1
0
29
1h
CloudKit container may need indexing
My queries are failing in an unusual way. I can query 4 out of 5 Record Types. The 5th fails from the app (CKQueryOperation) and, surprisingly, also from the CloudKit Dashboard. It returns only 100-300 records when it should return over 4000. Tapping "Query Records" returns an additional 100-300 records. Apple Developer Technical Support has suggested that the issue involves the index of the container and wrote that only the CloudKit Team can fix it. So my question is - How do I get the CloudKit Team to fix it????
3
0
92
1h
NSPersistentCloudKitContainer doesn't report "Quota Exceeded" through notification
When subscribing to NSPersistentCloudKitContainer.eventChangedNotification events, quota exceeded events aren't delivered to the app at runtime. I get CKError.partialFailure, but without any additional information in any of the properties. https://developer.apple.com/documentation/cloudkit/ckerror/code/partialfailure states information should be available, but it isn't. When a debugger is attached, the information is logged by another process, but my app cannot access that at runtime to provide users with additional information. Is there any workaround to get this to work? References: Older post: https://forums.developer.apple.com/forums/thread/696523 FB13773922
4
0
127
1h
Question on PCS Zone corruption recovery
Hi all - figured I would kick off with a CloudKit question. Recently in development of a multi-device app I got into a state where all iOS devices could not write to the (production) CloudKit container - however macOS could still write (multi-device SwiftUI code). After ruling out a lot of other things it seemed like there had been some corruption in the production zone's PCS key chain. The only fix was deleting the zone from the CloudKit Console (safe for my pre-release beta data, but destructive). Is there a safer or developer-accessible recovery path for PCS chain corruption? Is this situation detectable earlier, or is there guidance on avoiding it during pre-release testing? The error in the logs in this scenario had "overallStatus":"USER_ERROR", "error":"BAD_REQUEST", "returnedRecordTypes":"_pcs_data".
1
0
71
1h
CKSyncEngine for records with references
Is there any guidance for syncing records that have references to others regarding batching with the sync engine? For example, if I have hundreds of records to sync with many different types and references, do I need to keep track of how many records would be added because of reference properties? The sample and video doesn’t go into details about syncing records that have references to others so looking for lesser known rough edges.
1
0
35
2h
CloudKit with Swift on Server or Mac dev tools
What recommendation would you have for teams wanting to build a CloudKit integration in the cloud? For example, the backend writes data to the public database, users read it, controlled via security roles. CloudKit Web Services documentation has been archived for some time but the services still exist. Generating a client using Swift OpenAPI generator would be real slick. The same could be used in local tooling that has the server API key.
1
1
50
2h
App Privacy Report says app connecting to Google for CKDatabase
I have a CloudKit container that I share across several apps. when I look at the App Privacy Report for these apps, it reflects the app connecting to Google storage APIs. While Apple might host with Google, the perception for users is iCloud and Apple. Can something be done about this? FB16410232 (CloudKit: CloudKit requests contacting google upload servers unexpectedly in app privacy report)
Replies
1
Boosts
0
Views
34
Activity
33m
CloudKit client usage should be attributed to app for MetricKit network metrics
In the past I ran into issues where the CloudKit client SDK was not attributing network usage in MetricKit. Since MetricKit got a major update this year I’d like to make sure usage goes here agains the app. I would expect transfer metrics to also count for CKSyncEngine, or the CloudKit config for core/swift data too. Is this assumption correct? FB12673917 (CloudKit / MetricKit: CloudKit queries are not counting towards network transfer metrics in MetricKit - WWDC23 lab, possible missing URLSession 'attributedBundleIdentifier' not being set)
Replies
1
Boosts
0
Views
33
Activity
50m
How can I reliably refresh WidgetKit widgets across devices after SwiftData + CloudKit synchronization?
Hey, I'm building an app that uses App Intents to modify data stored in SwiftData and synced through CloudKit. My expectation is that these changes should eventually be reflected in my app's widgets across all of the user's devices (iPhone, iPad, and Mac). However, I'm struggling to find a reliable way to ensure widgets reload when the underlying data changes as a result of a CloudKit sync. Reloading widgets on the device that modifies the data works reliably. The challenge is ensuring widgets reload on other devices after the updated data has been synced through CloudKit. In practice, this doesn't appear to happen reliably. I do not expect the user to manually open the app on those devices. I'm fine with the system launching my app in the background if that's part of the intended solution. Is there a recommended approach for keeping widgets in sync with SwiftData and CloudKit across devices? More specifically: Can WidgetKit be notified when SwiftData receives updates from CloudKit? Is there any supported way to trigger widget reloads on remote devices after a CloudKit sync? If not, what is the recommended architecture for ensuring widgets stay reasonably up to date when synchronized data changes? Things I've considered and/or tried: Calling sendChanges(_:) on CKSyncEngine from my App Intent to push changes immediately. However, this depends on an active Internet connection and doesn't address the case where changes are made offline and synchronized to CloudKit at a later time. Sending push notifications to the user's devices after an App Intent runs and using WidgetPushHandler to reload widgets. However, this requires confidence that the changes have already been uploaded to CloudKit. As far as I can tell, that's difficult or impossible to guarantee in the general case because of the issue described above. Calling fetchChanges(_:) on CKSyncEngine from the widget's timeline provider to ensure the widget has the latest data. However, the widget first needs some indication that new changes are available in CloudKit. Additionally, widget timeline reloads appear to have fairly strict execution time limits, which makes performing CloudKit synchronization work in that context seem less than ideal. My goal is for a Shortcut run on one device to update data and have widgets on all of the user's devices reflect those changes without requiring the user to manually open the app on each device. Am I thinking about this problem correctly, or is there a recommended pattern I'm missing? I'd appreciate any guidance on the intended WidgetKit + SwiftData + CloudKit integration story for this scenario. Thanks!
Replies
3
Boosts
1
Views
86
Activity
50m
Recommended way to display user-friendly iCloud Drive paths?
I’m building a macOS app that stores file URLs/bookmarks and displays file locations in the UI. For files in iCloud Drive, I want to show a user-friendly path such as: iCloud Drive / My Folder / File.jpg rather than an internal filesystem path. What is the recommended way to display iCloud Drive paths in a way that matches what users see in Finder? Thanks!
Replies
1
Boosts
0
Views
41
Activity
51m
Add Analytics Reports for CloudKit usage
I don’t have a feedback for this yet, but I’d like to see some analytics reports for CloudKit performance. Things to capture stats, performance, failures, etc. lots of the data in the console, but exposed through analytics reports. Related but different, if I had something like a generated OpenAPI client, I’d add instrumentation via client middleware. I could do most of what I’d want to instrument that way, status codes, timeouts, durations, payload sizes, etc. Alternatively, if the CloudKit client API exposed URLSession, or a hook to the delegate / metrics, a lot of what I am interested in could be achieved via session task metrics too. FB13628463 (CloudKit: Expose URLSessionTaskMetrics from CloudKit client)
Replies
1
Boosts
0
Views
25
Activity
1h
Control Logging of CloudKit in Xcode
I often struggle to see my own log data with the heavy stream of CloudKit updates. Is there an easy way to filter that our or turn it on/off?
Replies
3
Boosts
0
Views
66
Activity
1h
Display state of iCloud files
I’m building a macOS app that displays a large grid of image thumbnails similar to Photos. What is the recommended way to determine whether a file is locally available/downloaded without making a blocking call to the filesystem for every thumbnail? Thanks!
Replies
4
Boosts
0
Views
89
Activity
1h
CloudKit security roles
I’d like the ability to detect a users security role. This makes sense for detecting the roles assigned to named users for enabling workflows within an app. For example, user generated content and “moderators”. Instead of building an unlisted app, I’d prefer to just check permissions against the user. As a workaround, one could create record types with the same “security role” as the moderator actions, but to attempt to fetch a dummy record seems fragile and inefficient. FB9638492 (CloudKit: API to detect provided security role on current user)
Replies
1
Boosts
0
Views
29
Activity
1h
CloudKit container may need indexing
My queries are failing in an unusual way. I can query 4 out of 5 Record Types. The 5th fails from the app (CKQueryOperation) and, surprisingly, also from the CloudKit Dashboard. It returns only 100-300 records when it should return over 4000. Tapping "Query Records" returns an additional 100-300 records. Apple Developer Technical Support has suggested that the issue involves the index of the container and wrote that only the CloudKit Team can fix it. So my question is - How do I get the CloudKit Team to fix it????
Replies
3
Boosts
0
Views
92
Activity
1h
Notification when iCloud Drive state changes
Is there any way to get notified in macOS when the iCloud Drive becomes online/offline so that I can update the UI in my app to reflect that state? Thanks!
Replies
1
Boosts
0
Views
47
Activity
1h
Cloudkit sharing available in swift instead Core Kit
Hi there, as far as I know CloudKit sharing is only available when using Core Kit coding instead swift. Are you okaying to open that posibility in further versions of swift?
Replies
6
Boosts
0
Views
119
Activity
1h
NSPersistentCloudKitContainer doesn't report "Quota Exceeded" through notification
When subscribing to NSPersistentCloudKitContainer.eventChangedNotification events, quota exceeded events aren't delivered to the app at runtime. I get CKError.partialFailure, but without any additional information in any of the properties. https://developer.apple.com/documentation/cloudkit/ckerror/code/partialfailure states information should be available, but it isn't. When a debugger is attached, the information is logged by another process, but my app cannot access that at runtime to provide users with additional information. Is there any workaround to get this to work? References: Older post: https://forums.developer.apple.com/forums/thread/696523 FB13773922
Replies
4
Boosts
0
Views
127
Activity
1h
Question on PCS Zone corruption recovery
Hi all - figured I would kick off with a CloudKit question. Recently in development of a multi-device app I got into a state where all iOS devices could not write to the (production) CloudKit container - however macOS could still write (multi-device SwiftUI code). After ruling out a lot of other things it seemed like there had been some corruption in the production zone's PCS key chain. The only fix was deleting the zone from the CloudKit Console (safe for my pre-release beta data, but destructive). Is there a safer or developer-accessible recovery path for PCS chain corruption? Is this situation detectable earlier, or is there guidance on avoiding it during pre-release testing? The error in the logs in this scenario had "overallStatus":"USER_ERROR", "error":"BAD_REQUEST", "returnedRecordTypes":"_pcs_data".
Replies
1
Boosts
0
Views
71
Activity
1h
CKSyncEngine for records with references
Is there any guidance for syncing records that have references to others regarding batching with the sync engine? For example, if I have hundreds of records to sync with many different types and references, do I need to keep track of how many records would be added because of reference properties? The sample and video doesn’t go into details about syncing records that have references to others so looking for lesser known rough edges.
Replies
1
Boosts
0
Views
35
Activity
2h
CloudKit with Swift on Server or Mac dev tools
What recommendation would you have for teams wanting to build a CloudKit integration in the cloud? For example, the backend writes data to the public database, users read it, controlled via security roles. CloudKit Web Services documentation has been archived for some time but the services still exist. Generating a client using Swift OpenAPI generator would be real slick. The same could be used in local tooling that has the server API key.
Replies
1
Boosts
1
Views
50
Activity
2h
Strategy for Limiting CloudKit Activity / Refreshing
Are there good ways to guide an app to pause iCloud syncing if the app is busy with an intensive activity? Also, is there a way to suggest that it check iCloud for updates?
Replies
1
Boosts
0
Views
49
Activity
2h