I have a database in CloudKit, where the host share (using CKShare) a record to participants. The record is in her private database, but for the participants is in their shared database. How do I send push notifications to everyone when a new child record is created?
CloudKit
RSS for tagStore structured app and user data in iCloud containers that can be shared by all users of your app using CloudKit.
Posts under CloudKit tag
200 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
Good Morning I am building a app that uses cloudkit and am trying to find our the app limits allowed
I have been trying to find out the app limits to my app when released into the app store, I understand that in the public database the app worldwide can use 200g of bandwidth free per month. What happens after that? is it throttled? is there a pricing structure for overages? thanks
Any idea what this message means? I assume it's coming from CloudKit, but the application seems to store and retrieve data properly.
Hi all,
I recently discovered that I forgot to deploy my CloudKit schema changes from development to production - an oversight that unfortunately went unnoticed for 2.5 months.
As a result, any data created during that time was never synced to iCloud and remains only in the local CoreData store. Once I pushed the schema to production, CloudKit resumed syncing new changes as expected.
However, this leaves me with a gap: there's now a significant amount of data that would be lost if users delete or reinstall the app.
Before I attempt to implement a manual backup or migration strategy, I was wondering:
Does NSPersistentCloudKitContainer keep track of local changes that couldn't be synced doe to the missing schema and automatically reattempt syncing them now that the schema is live?
If not, what would be the best approach to ensure this "orphaned" data gets saved to CloudKit retroactively.
Thanks in advance for any guidance or suggestions.
Hi. I am having this error when trying to write to CloudKit public database.
<CKError 0x600000dbc4e0: "Permission Failure" (10/2007); server message = "Invalid bundle ID for container";
On app launch, I check for account status and ensure that the correct bundle identifier and container is being used. When the account status is checked, I do get the correct bundle id and container id printed in the console but trying to read or write to the container would throw that "Invalid bundle ID for container" error.
private init() {
container = CKContainer.default()
publicDB = container.publicCloudDatabase
// Check iCloud account status
checkAccountStatus()
}
func checkAccountStatus() {
print("🔍 CloudKit Debug:")
print("🔍 Bundle identifier from app: (Bundle.main.bundleIdentifier ?? "unknown")")
print("🔍 Container identifier: (container.containerIdentifier ?? "unknown")")
container.accountStatus { [weak self] status, error in
DispatchQueue.main.async {
switch status {
case .available:
self?.isSignedIn = true
self?.fetchUserID()
case .noAccount, .restricted, .couldNotDetermine:
self?.isSignedIn = false
self?.errorMessage = "Please sign in to iCloud in Settings to use this app."
default:
self?.isSignedIn = false
self?.errorMessage = "Unknown iCloud account status."
}
print("User is signed into iCloud: \(self?.isSignedIn ?? false)")
print("Account status: \(status.rawValue)")
}
}
}
I have tried:
Creating a new container
Unselecting and selecting the container in signing & capabilities
Unselecting and selecting the container in App ID Configuration
I used to have swift data models in my code and read that swift data is not compatible with CloudKit public data so I removed all the models and any swift data codes and only uses CloudKit public database.
let savedRecord = try await publicDB.save(record)
Nothing seems to work. If anyone could help please?
Rgds,
Hans
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags:
CloudKit
Cloud and Local Storage
CloudKit Console
Hi. I'm hoping someone might be able to help us with an issue that's been affecting our standalone watchOS app for some time now.
We've encountered consistent crashes on Apple Watch devices when the app enters the background while the device is offline (i.e., no Bluetooth and no Wi-Fi connection). Through extensive testing, we've isolated the problem to the use of NSPersistentCloudKitContainer. When we switch to NSPersistentContainer, the crashes no longer occur.
Interestingly, this issue only affects our watchOS app. The same CloudKit-based persistence setup works reliably on our iOS and macOS apps, even when offline. This leads us to believe the issue may be specific to how NSPersistentCloudKitContainer behaves on watchOS when the device is disconnected from the network.
We're targeting watchOS 10 and above. We're unsure if this is a misconfiguration on our end or a potential system-level issue, and we would greatly appreciate any insight or guidance.
I have an app that uses CKShare to allow users to share CloudKit data with other users.
With the first build of the iOS 26, I'm seeing a few issues:
I'm not able to add myself as a participant anymore when I have the link to a document.
Some participants names no longer show up in the app.
Looking at the release notes for iOS & iPadOS 26 Beta, there is a CloudKit section with two bullets:
CloudKit sharing URLs do not launch third-party apps. (151778655)
The request access APIs, such as CKShareRequestAccessOperation, are available in the SDK but are currently nonfunctional. (151878020)
It sounds like the first issue is addressed by the first bullet, although the error message makes me wonder if I need to make changes to my iCloud account permissions or something in order to open it. It works fine in iOS 18.5. This is the error I get when I try to open a link to a shared document (I blocked out my email address, which is what was in quotes):
As far as the second issue, I am really confused about what is going on. Some names still show up, while others do not. I can't find a pattern, and the missing users are not on the iOS 26 beta. The release notes mention CKShareRequestAccessOperation being nonfunctional, which is new in the beta and has some minor documentation, but I can't find information about how it's supposed to be used yet.
In previous years there have been WWDC sessions about what's new in CloudKit, but I haven't found anything that talks about these changes to document sharing.
Is there a guide or session somewhere that I'm missing?
Does anyone know what's going on with these changes to CloudKit?
I was experiencing a weird sign in error when using apple sign in with my app and wanted to put it here for anyone else who might experience it in the future, and so apple can make this requirement more clear.
I was using CloudKit and apple sign in. If you are not using both this probably does not apply to you.
Every time I would go to sign in in the iOS simulator I would enter my password, hit "sign in", and everything just froze.
The very odd reason for this is if you are using iCloudKit and apple sign in you need to go to specifically the "identifiers" in the "Certificates, Identifiers & Profiles" menu (https://developer.apple.com/account/resources/identifiers/list). And from there you specifically need an App ID Configuration with apple sign in enabled.
From there you have to have the same exact bundle identifier in Xcode under project settings(not an upper tab just click your project in the left panel). And that should allow you to both pass validation and have your sign in work.
Hope this helps!
Topic:
Privacy & Security
SubTopic:
Sign in with Apple
Tags:
CloudKit
Sign in with Apple
iCloud Drive
I have an app that uses NSPersistentCloudKitContainer stored in a shared location via App Groups so my widget can fetch data to display. It works. But if you reset your iPhone and restore it from a backup, an error occurs:
The file "Name.sqlite" couldn't be opened. I suspect this happens because the widget is created before the app's data is restored. Restarting the iPhone is the only way to fix it though, opening the app and reloading timelines does not. Anything I can do to fix that to not require turning it off and on again?
We are trying to solve for the following condition with SwiftData + CloudKit:
Lots of data in CloudKit
Perform "app-reset" to clear data & App settings and start fresh.
Reset data models with try modelContext.delete(model:_) myModel.count() confirms local deletion (0 records); but iCloud Console shows expectedly slow process to delete.
Old CloudKit data is returning during the On Boarding process.
Questions:
• Would making a new iCloud Zone for each reset work around this, as the new zone would be empty? We're having trouble finding details about how to do this with SwiftData.
• Would CKSyncEngine have a benefit over the default SwiftData methods?
Open to hearing if anyone has experienced a similar challenge and how you worked around it!
Hello,
I'm working on a Unity game which uses Apple Arcade Cloudkit Unity plugin. Cloud save works on all platforms except visionOS. I tried to debug using visionOS 2.4 Simulator. When the game starts XCode display the following error:
DllNotFoundException: Unable to load DLL 'CloudKitWrapper'. Tried the load the following dynamic libraries: Unable to load dynamic library '/CloudKitWrapper' because of 'Failed to open the requested dynamic library (0x06000000) dlerror() = dlopen(/CloudKitWrapper, 0x0005): tried: '/Users/seb/Library/Developer/Xcode/DerivedData/Unity-VisionOS-akwybgjotadlwrghmmfkhbhpuduf/Build/Products/Debug-xrsimulator/CloudKitWrapper' (no such file), '/Library/Developer/CoreSimulator/Volumes/xrOS_22O237/Library/Developer/CoreSimulator/Profiles/Runtimes/xrOS 2.4.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/introspection/CloudKitWrapper' (no such file), '/Library/Developer/CoreSimulator/Volumes/xrOS_22O237/Library/Developer/CoreSimulator/Profiles/Runtimes/xrOS 2.4.simruntime/Contents/Resources/RuntimeRoot/CloudKitWrapper' (no such file), '/CloudKitWrapper' (no such file)
at Apple.CloudKit.CKContainer.CKContainer_Default () [0x00000] in <00000000000000000000000000000000>:0
at Apple.CloudKit.CKContainer.Default () [0x00000] in <00000000000000000000000000000000>:0
I opened up the "Debug-xrsimulator" and indeed there is no CloudKitWrapper. However, if I "show content" on the app and navigate to the "Frameworks" folder, all Apple Arcade plugins are here, including CloudKit. I guess the plugin is in the right location, but the code tries to load it from the wrong path.
I have used core data before via the model editor. This is the first time I'm using swift data and that too with CloudKit. Can you tell me if the following model classes are correct?
I have an expense which can have only one sub category which in turn belongs to a single category. Here are my classes...
// Expense.swift
// Pocket Expense Diary
//
// Created by Neerav Kothari on 16/05/25.
//
import Foundation
import SwiftData
@Model
class Expense {
@Attribute var expenseDate: Date? = nil
@Attribute var expenseAmount: Double? = nil
@Attribute var expenseCategory: Category? = nil
@Attribute var expenseSubCategory: SubCategory? = nil
var date: Date {
get {
return expenseDate ?? Date()
}
set {
expenseDate = newValue
}
}
var amount: Double{
get {
return expenseAmount ?? 0.0
}
set {
expenseAmount = newValue
}
}
var category: Category{
get {
return expenseCategory ?? Category.init(name: "", icon: "")
}
set {
expenseCategory = newValue
}
}
var subCategory: SubCategory{
get {
return expenseSubCategory ?? SubCategory.init(name: "", icon: "")
}
set {
expenseSubCategory = newValue
}
}
init(date: Date, amount: Double, category: Category, subCategory: SubCategory) {
self.date = date
self.amount = amount
self.category = category
self.subCategory = subCategory
}
}
//
// Category.swift
// Pocket Expense Diary
//
// Created by Neerav Kothari on 16/05/25.
//
import Foundation
import SwiftData
@Model
class Category {
@Attribute var categoryName: String? = nil
@Attribute var categoryIcon: String? = nil
var name: String {
get {
return categoryName ?? ""
}
set {
categoryName = newValue
}
}
var icon: String {
get {
return categoryIcon ?? ""
}
set {
categoryIcon = newValue
}
}
@Relationship(inverse: \Expense.expenseCategory) var expenses: [Expense]? = []
init(name: String, icon: String) {
self.name = name
self.icon = icon
}
}
// SubCategory.swift
// Pocket Expense Diary
//
// Created by Neerav Kothari on 16/05/25.
//
import Foundation
import SwiftData
@Model
class SubCategory {
@Attribute var subCategoryName: String? = nil
@Attribute var subCategoryIcon: String? = nil
var name: String {
get {
return subCategoryName ?? ""
}
set {
subCategoryName = newValue
}
}
var icon: String {
get {
return subCategoryIcon ?? ""
}
set {
subCategoryIcon = newValue
}
}
@Relationship(inverse: \Expense.expenseSubCategory) var expenses: [Expense]? = []
init(name: String, icon: String) {
self.name = name
self.icon = icon
}
}
The reason why I have wrappers is the let the existing code (before CloudKit was integrated), work.
In future versions I plan to query expenses even via category or sub category. I particularly doubt for the relationship i have set. should there be one from category to subcategory as well?
Background:
Our non-production App was using SwiftData locally. Yesterday we followed the documentation to enable CloudKit: https://developer.apple.com/documentation/cloudkit/enabling-cloudkit-in-your-app
iCloud Works: Data is properly syncing via iCloud between 2 devices. Add on one shows on the other; delete on one deletes on the other.
Today we logged into CloudKit Console for the first time; but there are no databases showing.
We verified:
Users and Roles: we have “Access to Cloud Managed… Certificates”
Certificates, Identifiers & Profiles: our app has iCloud capabilities and is using our iCloud Container
Signed into CloudKit Console with same developer ID as AppStoreConnect
This is also the Apple ID of the iCloud account that has synced data from our app.
In Xcode > Signing & Capabilities we are signed in as our Company team.
Any guidance or tips to understanding how to what’s going on in CloudKit Console and gaining access to the database is appreciated!
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags:
CloudKit
CloudKit Dashboard
CloudKit Console
I am trying to save to cloud kit shared database. The shared database does not allow zones to be set up.
How do I save to sharedCloudDatabase without a zone?
private func addItem(recordType: String, name: String) {
let record = CKRecord(recordType: recordType)
record[Constances.field.name] = name as CKRecordValue
record[Constances.field.done] = false as CKRecordValue
record[Constances.field.priority] = 0 as CKRecordValue
CKContainer.default().sharedCloudDatabase.save(record) { [weak self] returnRecord, error in
if let error = error {
print("Error saving record: \(record[Constances.field.name] as? String ?? "No Name"): \n \(error)")
return
}
}
}
The following error message prints out:
Error saving record: Milk:
<CKError 0x15af87900: "Server Rejected Request" (15/2027); server message = "Default zone is not accessible in shared DB"; op = B085F7BA703D4A08; uuid = 87AEFB09-4386-4E43-81D7-971AAE8BA9E0; container ID = "iCloud.com.sfw-consulting.Family-List">
Blocker: Registering simulator runtime with CoreSimulator failed.
I am following Apple's instruction to sync SwiftData with CloudKit. While initiating the ModelContainer, right after removing the store from Core Data, the error occurs:
FAULT: NSInternalInconsistencyException: This NSPersistentStoreCoordinator has no persistent stores (unknown). It cannot perform a save operation.; (user info absent)
I've tried removing default.store and its related files/folders before creating the ModelContainer with FileManager but it does not resolve the issue. Isn't it supposed to create a new store when the ModelContainer is initialized? I don't understand why this error occurs. Error disappears when I comment out the #if DEBUG block.
Code:
import CoreData
import SwiftData
import SwiftUI
struct InitView: View {
@Binding var modelContainer: ModelContainer?
@Binding var isReady: Bool
@State private var loadingDots = ""
@State private var timer: Timer?
var body: some View {
VStack(spacing: 16) {
Text("Loading\(loadingDots)")
.font(.title2)
.foregroundColor(.gray)
}
.padding()
.onAppear {
startAnimation()
registerTransformers()
let config = ModelConfiguration()
let newContainer: ModelContainer
do {
#if DEBUG
// Use an autorelease pool to make sure Swift deallocates the persistent
// container before setting up the SwiftData stack.
try autoreleasepool {
let desc = NSPersistentStoreDescription(url: config.url)
let opts = NSPersistentCloudKitContainerOptions(containerIdentifier: "iCloud.my-container-identifier")
desc.cloudKitContainerOptions = opts
// Load the store synchronously so it completes before initializing the
// CloudKit schema.
desc.shouldAddStoreAsynchronously = false
if let mom = NSManagedObjectModel.makeManagedObjectModel(for: [Page.self]) {
let container = NSPersistentCloudKitContainer(name: "Pages", managedObjectModel: mom)
container.persistentStoreDescriptions = [desc]
container.loadPersistentStores { _, err in
if let err {
fatalError(err.localizedDescription)
}
}
// Initialize the CloudKit schema after the store finishes loading.
try container.initializeCloudKitSchema()
// Remove and unload the store from the persistent container.
if let store = container.persistentStoreCoordinator.persistentStores.first {
try container.persistentStoreCoordinator.remove(store)
}
}
// let fileManager = FileManager.default
// let sqliteURL = config.url
// let urls: [URL] = [
// sqliteURL,
// sqliteURL.deletingLastPathComponent().appendingPathComponent("default.store-shm"),
// sqliteURL.deletingLastPathComponent().appendingPathComponent("default.store-wal"),
// sqliteURL.deletingLastPathComponent().appendingPathComponent(".default_SUPPORT"),
// sqliteURL.deletingLastPathComponent().appendingPathComponent("default_ckAssets")
// ]
// for url in urls {
// try? fileManager.removeItem(at: url)
// }
}
#endif
newContainer = try ModelContainer(for: Page.self,
configurations: config) // ERROR!!!
} catch {
fatalError(error.localizedDescription)
}
modelContainer = newContainer
isReady = true
}
.onDisappear {
stopAnimation()
}
}
private func startAnimation() {
timer = Timer.scheduledTimer(
withTimeInterval: 0.5,
repeats: true
) { _ in
updateLoadingDots()
}
}
private func stopAnimation() {
timer?.invalidate()
timer = nil
}
private func updateLoadingDots() {
if loadingDots.count > 2 {
loadingDots = ""
} else {
loadingDots += "."
}
}
}
import CoreData
import SwiftData
import SwiftUI
@main
struct MyApp: App {
@State private var modelContainer: ModelContainer?
@State private var isReady: Bool = false
var body: some Scene {
WindowGroup {
if isReady, let modelContainer = modelContainer {
ContentView()
.modelContainer(modelContainer)
} else {
InitView(modelContainer: $modelContainer, isReady: $isReady)
}
}
}
}
I have tried to set up iCloud sync. Despite fully isolating and resetting my development environment, the app fails with:
NSCocoaErrorDomain Code=134060 (PersistentStoreIncompatibleVersionHashError)
What I’ve done:
Created a brand new CloudKit container
Created a new bundle ID and app target
Renamed the Core Data model file itself
Set a new model version
Used a new .sqlite store path
Created a new .entitlements file with the correct container ID
Verified that the CloudKit dashboard shows no records
Deleted and reinstalled the app on a real device
Also tested with “Automatically manage signing” and without
Despite this, the error persists. I am very inexperienced and am not sure what my next step is to even attempt to fix this. Any guidance is apprecitated.
Hi all,
I’m encountering a consistent issue with SwiftData on watchOS when using CloudKit sync. After enabling:
let config = ModelConfiguration(schema: schema, cloudKitDatabase: .automatic)
…the app terminates ~30–60 seconds into a WKExtendedRuntimeSession. This happens specifically when:
Always-On Display is OFF
The iPhone is disconnected or in Airplane Mode
The app is running in a WKExtendedRuntimeSession (e.g., used for meditation tracking)
The Xcode logs show a warning:
Background Task ("CoreData: CloudKit Setup"), was created over 30 seconds ago. In applications running in the background, this creates a risk of termination.
It appears CloudKit sync setup is being triggered automatically and flagged by the system as an unmanaged long-running task, leading to termination.
Workaround:
Switching to:
let config = ModelConfiguration(schema: schema, cloudKitDatabase: .none)
…prevents the issue entirely — no background task warning, no crash.
Feedback ID submitted: FB17685611
Just wanted to check if others have seen this behavior or found alternative solutions. It seems like something Apple may need to address in SwiftData’s CloudKit handling on watchOS.
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags:
CloudKit
watchOS
Background Tasks
SwiftData
Hi everyone,
We’re currently using CKSyncEngine to sync all our locally persisted data across user devices (iOS and macOS) via iCloud.
We’ve noticed something strange and reproducible:
On iOS, when the CKSyncEngine is initialized with manual sync behavior, both manual calls to fetchChanges() and sendChanges() happen nearly instantly (usually within seconds). Automatic syncing is also very fast.
On macOS, when the CKSyncEngine is initialized with manual sync behavior, fetchChanges() and sendChanges() are also fast and responsive.
However, once CKSyncEngine is initialized with automatic syncing enabled on macOS:
sendChanges() still appears to transmit changes immediately.
But automatic fetching becomes significantly slower — often taking minutes to pick up changes from the cloud, even when new data is already available.
Even manual calls to fetchChanges() behave as if they’re throttled or delayed, rather than performing an immediate fetch.
Our questions:
Is this delay in automatic (and post-automatic manual) fetch behavior on macOS expected, or possibly a bug?
Are there specific macOS constraints that impact CKSyncEngine differently than on iOS?
Once CKSyncEngine has been initialized in automatic mode, is fetchChanges() no longer treated as a truly manual trigger?
Is there a recommended workaround to enable fast sync behavior on macOS — for example, by sticking to manual sync configuration and triggering sync using a CKSubscription-based mechanism when remote changes occur?
Any guidance, clarification, or experiences from other developers (or Apple engineers) would be greatly appreciated — especially regarding maintaining parity between iOS and macOS sync performance.
Thanks in advance!
My project is using swiftData and I want to implement iCloud sync in it. Now, my data base doesnt have any optional attributes or relationships and CloudKit wants them to be optional.
So, rather than editing all code with unwrapping code for the optionals, how can I provide a bridge that does so in the last stage of actually saving to the store? Sort of, capture it in a proxy object before writing and after reading from the store.
Is there a neat way that can save a lot of debugging? I have code snippets from chat gpt and they are hard to debug. This is my first project in swiftUI.
Thanks.
Neerav