2,368 questions
Best practices
0
votes
1
replies
89
views
What is the correct way to initialize a Data property in a model object in SwiftData / CloudKit?
I have a model class in my app which uses SwiftData / CloudKit:
@Model
final class Project
{
var name: String = ""
var avatarData: Data?
var hasAvatar: Bool = false
...
...
Best practices
0
votes
1
replies
76
views
Core Data relationships (constraints) not reflected in CloudKit schema – expected behavior or misconfiguration?
I’m working on an iOS app using Core Data with CloudKit synchronization (NSPersistentCloudKitContainer).
In my Core Data model, I have defined relationships between entities (e.g. 1:n and n:m). These ...
0
votes
0
answers
46
views
NSPersistentCloudKitContainer.share() deadlocks - only works in CKShareTransferRepresentation.prepareShare
I am building an iOS 26 SwiftUI app with Swift 6 strict concurrency using NSPersistentCloudKitContainer with a private and shared store for CloudKit zone-based sharing.
The goal
I want to share a Core ...
2
votes
0
answers
29
views
CloudKit, cannot deploy private database initial schema to production
We’re using a private database with a custom zone. Record types and related schema are created programmatically rather than through the dashboard.
When running the app in the development environment, ...
0
votes
0
answers
57
views
CloudKit records not deleted when removed from iOS app
For an unknown reason, when I delete a record in my app, the CloudKit record does not delete. So the next time the app runs, the "deleted" records come back.
I add the records as follows:
...
0
votes
0
answers
80
views
Remove entity from NSPersistentCloudKitContainer
I'm using NSPersistentCloudKitContainer and I have added an entity (to the private database) to the core data model. Now I have realised that I don't need that entity anymore and I want to get rid of ...
3
votes
2
answers
87
views
Capture of 'objectIDNotifications' with non-Sendable type '[Notification]' in a '@Sendable' closure
I'm using Swift5 and SwiftUI making an app that based on CloudKit.
I've made the merge data from iCloud function and it looks work well. But I always get a warning like "Capture of '...
Best practices
0
votes
2
replies
107
views
SwiftData / CloudKit: Best practices for adding / removing to / from a child model object array
In SwiftData / CloudKit, when you have a root model object, it's pretty straightforward when you want to add or delete it from the model: simply use a modelContext variable and use its insert and ...
Advice
0
votes
2
replies
136
views
CloudKit data initial share sheet in Swift UI and iOS 26
Let's use a basic todo app as an example - sharing a todo list. I have a share button (square with up arrow) that when the user taps I want the initial share sheet to appear. If I have to create and ...
0
votes
1
answer
88
views
CKQueryOperation parse Array from public database [closed]
The operation:
operation.recordMatchedBlock = {recordID, result in
switch result {
case .success(let record):
print("RecordID: \(recordID), record: \(record)")
let ...
6
votes
1
answer
108
views
CloudKit Web Services Server-to-server Authentication failed using PHP
I've been trying to get the server to server request for quite some time, but unfortunately
I keep getting this error:
2025-11-19T03:19:29Z:"mybody":/database/1/"mycontainer"/...
0
votes
0
answers
68
views
macOS/iOS app CloudKit only syncs after app is force quite, or device is locked and unlocked
The core issue seems to be that while we receive CloudKit notifications and can access the data after app restart, the
NSPersistentCloudKitContainer doesn't seem to be processing remote changes in ...
2
votes
1
answer
118
views
SwiftUI iCloud Drive app folder not showing in Files app
I’m building a SwiftUI app that integrates with iCloud Drive. The goal is for the app’s Documents folder to appear in the user’s iCloud Drive, just like other apps that expose their folders.
I have ...
1
vote
0
answers
103
views
Sync not working for independent watchOS app using CloudKit and SwiftData
I'm working on an independent watchOS app and I was looking for the best solution to persist data locally and have an online sync with the iCloud storage.
I've found out about the SwiftData which is ...
0
votes
1
answer
108
views
How to share CKRecord with UIActivityViewController?
This is a warning I had when trying to use UICloudSharingController with preparationHandler:
Use -[UIActivityViewController initWithActivityItemsConfiguration:] and pass it a ...
3
votes
1
answer
209
views
CloudKit remote notifications in macOS get clogged up
I have a macOS app which uses CloudKit. I'm trying to deliver remote notifications for database record changes, but I didn't get any notifications through.
I've set everything correctly and according ...
0
votes
0
answers
112
views
"Invalid bundle ID for container" error when using multiple bundle identifiers for Debug and Release builds
Background:
My app successfully uses CloudKit syncing, and syncing works reliably in general.
I'm using multiple .xcconfig files to distinguish between Debug and Release builds.
These define ...
0
votes
2
answers
181
views
List won't update when item is deleted
I have two selectable lists, the first is populated with Category model objects and the second with Subcategory model objects (which are taken from selected Category value of the first list).
When I ...
1
vote
0
answers
115
views
See owner name when joining a public shared iCloud CKRecord through a CKShare on iOS 26
I have an iOS app that uses CloudKit to allow users to share data with other users through iCloud.
One user joins another user's record through the shareURL from a CKShare created by the record owner, ...
0
votes
0
answers
81
views
How to allow Cloud Encryption in CoreData and CloudKit?
How to migrate if the following problem occurs?
The current Coredata and CloudKit database contains records which do not use allowCloudEncryption. Since we thought of advanced data protection for user'...
1
vote
1
answer
164
views
Avoid duplicate CKRecords when syncing SwiftData with CloudKit
The app I'm working on aims to show its users one unique Item per day. The Item has an associated ItemText and ItemImage. All Items are created when the user installs the app (see the create() ...
0
votes
0
answers
39
views
Is it possible to revert committed deletion from Core Data Cloudkit in Swift?
A user has accidentally deleted a root record that removes all data from the user. The data is stored in Cloudkit CoreData with Transaction History enabled.
I have noticed in the CoreData database ...
0
votes
1
answer
58
views
How to tell the source of the changed coredata objects in NSManagedObjectContextObjectsDidChange
I need to know the source of the changed coredata objects returned from NSManagedObjectContextObjectsDidChange. I have some shared objects, and want to send a notification if the source is other than ...
0
votes
0
answers
19
views
Cloudkit references do not reflect coredata relationships
In core-data I have a contact and location entity. I have one-to-many relationship from contact to locations and one-to-one from location to contact. I create contact in a seperate view and save it. ...
0
votes
1
answer
68
views
App data update issue thru Core data sync to CloudKit
I have setup push notifications and updates in CK are updating UI well.
The issue I have is Syncing between Core Data and CK.
It's set to use NSPersistentCloudKitContainer with ...
0
votes
0
answers
62
views
Share iCloud Drive folder with Swift
Is it possible to programmatically create a shared iCloud Drive folder and then generate a link for external users to access it?
For instance, myApp utilizes iCloud Drive for storing certain files. ...
0
votes
1
answer
274
views
CloudKit & NSPersistentCloudKitContainer - Fetch the CKRecord of creatorUserRecordID for every CKRecord in public database
I wasn't sure how to phrase the question. I know it's misleading.
Context:
I'm using NSPersistentCloudKitContainer for my public and private database. The CoreData model has two configurations: Local, ...
1
vote
1
answer
215
views
How to Share a CloudKit Record with Multiple Participants While Keeping some Individual Records Private to each Participant?
In a CloudKit private database, the Owner creates a custom zone and performs the following actions:
Creates CKRecord1 with CKShare1 and invites Participant1 to it.
Creates CKRecord2 with CKShare2 and ...
0
votes
0
answers
96
views
SwiftUI / SwiftData / CloudKit: how to make custom binding for dynamically changing setter value
In my app, I have a class called Project:
import Foundation
import SwiftData
@Model
class Project
{
@Relationship(deleteRule: .nullify, inverse: \ProjectType.projects) var projectType: ...
0
votes
1
answer
95
views
How to populate database only once
I want to pre-populate the user's database the first time the app is used. This is what I have:
func checkAndPopulateData(modelContext: ModelContext) {
let fetchRequest = FetchDescriptor<...
1
vote
0
answers
82
views
Why is data not encrypted on icloud.developer.apple.com when i am using encrypted field
Here is my sample code of integration with iCloud
let dbName = "GroceryItem1"
let fieldName = "todoTitle1"
@objc func saveItem(name: String) {
let record = CKRecord(...
3
votes
1
answer
105
views
Predicate does not support keypaths with multiple components
today I encountered a strange error that’s blocking my progress. I wanted to add CloudKit support to an app that’s already using SwiftData for saving data. I read that 'All properties must either have ...
1
vote
0
answers
67
views
Silent push notifications not working on some iOS devices
I send APNs notifications to my devices with the CloudKit dashboard. I test with two devices;
Device with Silent Push Working Successfully:
iOS version 16.5.1 (c), Model iPhone Xs
Silent Push Failed ...
2
votes
0
answers
77
views
CKUserIdentity `nameComponents` is Empty
My App requires that the user has and allows iCloud access. With that access I expect to be able to access the users name. Yet, the following code produces an empty nameComponents result from ...
0
votes
1
answer
615
views
SwiftData issue adding model objects when syncing to CloudKit
I'm building a simple app that persists data using the SwiftData framework with the additional capability of syncing through CloudKit across devices.
All was well until I added a second model object. ...
1
vote
1
answer
277
views
Why isn't SwiftData updating the items in a ForEach loop when synced with iCloud but it does if just used with a List
I have an app that uses SwiftData which is set to be synced with iCloud.
When I run the app in the simulator and on an actual device simultaneously and then amend the customer name on the simulator ...
1
vote
0
answers
80
views
Does CloudKit guarantee CKRecord.Reference is always valid?
I'm considering using CloudKit in my app (it doesn't use Core Data) and have read as many materials as I can find. I haven't fully grasped it yet and have a basic question on CKRecord.Reference. Does ...
0
votes
1
answer
122
views
How to make a Range key value compliant in CloudKit?
In my app (which utilizes SwiftUI, SwiftData and CloudKit), I have the following class and enum:
@Model
class CategoryType
{
var name: String = ""
var parameterType: ...
0
votes
1
answer
294
views
How to handle data migration when using CloudKit?
General problem
I have an iOS app which uses Core Data with CloudKit and I reached the point where I need to evolve the schema and migrate existing data.
Schema changes
What I need is adding a new ...
1
vote
1
answer
229
views
Persisting data with objects that can have default predefined values and user generated values
I'm developing an app using SwiftData and CloudKit that presents the user with a selectable List of movie genres to choose from, populated from an enum and another array of objects (more on this in a ...
0
votes
0
answers
147
views
How to cache CKRecords efficiently in SwiftUI
I'm building a SwiftUI social photo-sharing app that uses CloudKit, where user profiles (including a CKAsset for profile pictures) are displayed throughout the app. To reduce redundant fetching of ...
0
votes
1
answer
55
views
Cloudkit records disappeared
App crashed showing error index out of range. In cloudkit dashboard, querying the table showed half of the records missing.
No changes were made neither to the app nor the database since the last ...
1
vote
0
answers
78
views
Why is an implicitly set relationship property crashing when I'm trying to access it? [duplicate]
I'm using SwiftData with CloudKit and I have the following two classes:
@Model
class Category
{
@Relationship(deleteRule: .cascade, inverse: \Book.category) var books : [Book]?
var project: ...
1
vote
0
answers
547
views
Improving iCloud Sync Speed for SwiftData in iOS and watchOS Apps
I'm developing an iOS app (for iPhone and iPad) with a watchOS companion app using SwiftData and iCloud. I've set up the following:
SwiftData model with optional/default parameters
iCloud capability ...
1
vote
0
answers
105
views
Do You Need 2 Bundle Ids and 2 Targets to Use Swift Data and CloudKit for Dev and Prod?
I’m using Swift Data and CloudKit, with a private container.
When developing my understanding is that you should have a target with com.apple.developer.icloud-container-environment key set to “...
-1
votes
1
answer
109
views
Child view not rendering when adding @Query macro - Infinite loop
For some reason when I add an @Query macro to my child view it fails to render. If I simplify my child view by just adding a plain text field while still leaving the @Query macro it still won't render....
1
vote
1
answer
465
views
How to solve relationship issues with SwiftData / CloudKit?
I have the following model set up in my app which utilizes SwiftData and Cloudkit. A Project object has an array of Book objects. A Book object has an array of Reader objects. A Reader object has an ...
0
votes
1
answer
197
views
How to make CloudKit compatible when you have enum driven selectable list
For a book club app I'm writing In SwiftUI, I have a NavigationSplitView that has a selectable List on its leading column. The first item on the list is "Book" and will take the user to a ...
2
votes
0
answers
143
views
SwiftData migration with iCloud and multi-device support
I’m writing test apps using SwiftData. Running migrations locally works fine. But I couldn’t find anything on how to handle a situation, where my local app is running on e.g. ‘MigrationSchemaV2’ and ...
1
vote
0
answers
827
views
Using SwiftData how does one sync a public database?
I have an iOS project with CloudKit, Background, and Remote Notifications enabled.
I have specified an @Model type that matches the name of the record in the CloudKit database.
But when I created the @...