I am following this document from Apple to implement sharing with CloudKit. In it, Apple says NSPersistentCloudKitContainer uses CloudKit zone sharing to share objects. Each share has its own record zone on the CloudKit server. CloudKit has a limit on how many record zones a database can have. What is the record zone limit for a private CloudKit database? I can find information about record and participant limits but not on record zone limits.
Search results for
NSPersistentCloudKitContainer
589 results found
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I've not experience that with UserDefaults. I wouldn't give up on finding that issue. But anything I want protected in cases where a user might lose or change their device, I use CoreData with NSPersistentCloudKitContainer. Which is easy to remember if you watch this video as this Nick Gillet says it 1.5 times per minute.
Topic:
App & System Services
SubTopic:
General
Tags:
The Statement I have a SwiftUI app that uses CoreData and iCloud with NSPersistentCloudKitContainer prepared for beta testing via TestFlight. The app utilizes iCloud solely as a private database for user data across different devices. The app doesn't use any public or shared database. According to Apple's guidelines, deploying the development schema to production is necessary before submitting to the App Store: Before you publish your app, you must deploy the development schema to the production environment to copy over its record types, fields, and indexes. I am aware that once deployed to production, it's impossible to delete or modify any types or fields: To prevent conflicts, you can’t delete record types or fields that are already in production. Every time you deploy the development schema, its additive changes merge into the production schema. The Questions: When is the appropriate time to deploy the schema to production? Should it be done before beta testing via TestFlight, or is it sufficient
Topic:
App Store Distribution & Marketing
SubTopic:
General
Tags:
App Store
CloudKit
TestFlight
Core Data
What interfaces do I use to propagate a CloudKit change in a shared zone to a notification/badge to all participants in the shared zone? Assume I have a 'League' that is the root object in a shared zone and that N Players are members of the league. One of the players, the 'organizer', schedules a 'Game' that is open to any of the players. When the organizer creates the game (in the league's shared zone) and it is mirrored in CloudKit, how can the other players see it (as a timely notification)? I already observe .NSPersistentStoreRemoteChange on NSPersistentStoreCoordinator and NSPersistentCloudKitContainer.eventChangedNotification on NSPersistentCloudKitContainer. Are these delivered in the background? Can/Should they generate a 'local/remote' notification for handling at the AppDelegate level? How? Do I need to use a CKDatabaseSubscription looking for CD_Game records directly? (I'd rather not; because then I'd have a potential race between the remote iCloud database(s) and the local CoreData)
We will need a feedback report with a sysdiagnose to investigate why the server is unhappy with your request. Typically these are configuration issues of some kind. https://developer.apple.com/documentation/technotes/tn3163-understanding-the-synchronization-of-nspersistentcloudkitcontainer#Capture-a-sysdiagnose
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
this project is using CloudKit for persistence through SwiftData... In order to use CloudKit's sharing APIs, such as CKShare.Participant, which contains the info you'd like to access, you'd need to implement a coexistence approach with Core Data and SwiftData. In iOS 17 SwiftData can express only a subset of NSPersistentCloudKitContainer's capabilities, and CloudKit sharing isn't one of them. That said, does your app have a use for CloudKit sharing? If not, and if your app is for macOS, you could use NSFullUserName(). In the event someone is using CloudKit sharing and needs to access the current user's name components, I found that using a CKShare directly works in iOS 17: func fetchCurrentUsername(for share: CKShare) -> String { var name = let currentUser = share.currentUserParticipant if let nameComponents = currentUser?.userIdentity.nameComponents { name = nameComponents.formatted() } return name }
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags:
I enabled Core Data + CloudKit for my MacOS and iOS app to allow sync between the two. I was able to test the sync during development and it's been syncing to My development database container just fine and I can fetch the changes from both my apps. However, once I distributed my app to test flight/app store, the Production database is not getting any activity at all. I did made sure I deploy my database schema to production per other troubleshooting post online. Am I missing any additional setup required for production? Below is my Persistence struct for reference (edited the App Name, using the the name of my app in actual file): static let shared = PersistenceController() let container: NSPersistentCloudKitContainer init(inMemory: Bool = false) { container = NSPersistentCloudKitContainer(name: App Name) // Only initialize the schema when building the app with the // Debug build configuration. #if DEBUG do { // Use the container to initialize the development schema. try container.initializ
So... the root cause of this issue is that you're calling recordID(for:) on the main thread during container setup (it looks like there is a fairly substantial import at the time you call it). NSPersistentCloudKitContainer can't concurrently serialize records and perform other work. You could file an enhancement request for that, but that would come with other consequences (like cache-miss issues for records that are in the process of being serialized). You can move this call to a background queue to avoid blocking the main thread's run loop on this work. As an aside, it looks like you're attempting to use the CKRecordID to coordinate data across multiple sync mechanisms. This is unlikely to lead to success. While it is exceedingly rare NSPersistentCloudKitContainer reserves the right to change the recordID for a managed object. We recommend that clients invent a foreign key of their own that they can pass to the other sync mechanism as a way of tracking related data.
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags:
I'm experiencing an unresponsive UI since MacOS 14.0 and iOS 17.0 when calling record(for: ) or recordID(for:) on the instance of NSPersistentCloudKitContainer. On MacOS, the UI freeze almost always happens when calling the function. On iOS, it is necessary that the device (or simulator) does not have any network connection. I would like to ask if anyone experienced the same problem. I have posted the problem twice to Apple via the Feedback app (once for iOS and once for MacOS). No reply yet on MacOS but on iOS Apple marked it as resolved because apparently no one but me has experienced this problem. In the meantime, I have set up a minimum reproducible example app (MRE).: https://github.com/DominikButz/NotesApp-Cloud-Kit-Record-UI-Freeze- Anyone interested, please read the readme of the repository. It includes step by step instructions on how to reproduce the bug. I can't rule out I have misunderstood the usage of CoreData and CloudKit - in that case please point me in the right direction. The app I
In Core data public configuration, added new attribute to entities, new entities, but the changes are neither synchronized nor data is transferred to existing container schema in cloudkit. private var _publicPersistentStore: NSPersistentStore? var publicPersistentStore: NSPersistentStore { return _publicPersistentStore! } private var _privatePersistentStore: NSPersistentStore? var privatePersistentStore: NSPersistentStore { return _privatePersistentStore! } private var _sharedPersistentStore: NSPersistentStore? var sharedPersistentStore: NSPersistentStore { return _sharedPersistentStore! } static let shared = PersistenceController() static var preview: PersistenceController = { let result = PersistenceController(inMemory: true) let viewContext = result.container.viewContext do { try viewContext.save() } catch { // Replace this implementation with code to handle the error appropriately. // fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping
Both methods experience delays when synchronizing a large amount of data at once. We are using two methods: During the initial installation, we call the below code to receive synchronization data and provide a user experience indicating that synchronization is in progress. public extension NSPersistentCloudKitContainer { func waitForCloudKitEvents(timeout: Int) async throws -> NSPersistentCloudKitContainer.Event? { let affectedStores = persistentStoreDescriptions .filter { description in description.cloudKitContainerOptions != nil } .compactMap { description -> NSPersistentStore? in guard let url = description.url else { return nil } return persistentStoreCoordinator.persistentStore(for: url) } let context = newBackgroundContext() let request = NSPersistentCloudKitContainerEventRequest.fetchEvents(after: .distantPast) request.resultType = .events request.affectedStores = affectedStores for seconds in 0...timeout { await Task.sleep(seconds: 1) let results: NSPersistentStoreResult = try context.e
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags:
In our app, there is a scenario where we write and delete approximately 100MB of files to the iCloud server at once using NSPersistentCloudkItContainer(CoreData). While write, read, and delete operations are immediately reflected in the local database, there is a noticeable delay when accessing the CloudKit Database dashboard. Here is the testing approach we have tried: Data Insert Test
Prepare around 100MB of data.
Write the data to CoreData on device A.
When launching the app on device B, it takes about 5 minutes for the data to be fully synchronized. Data Deletion Test Remove all the added data on device A (immediately reflected in local storage.)
After performing step 1, leaving device A idle takes about 3 minutes for the deletion to be reflected on device B.
if the app is deleted on device A after step 1, deletion information does not reach device B. Upon reinstalling the app on device A, the deleted data reappears on device B (synchronized data). The ongoing occurrence of these issues has
Thank you for your reply. I have tried something like the following, however the quotaExceeded never gets printed even though the above error message does. I can see also that the code enters the .partialFailure section of the if, however ckerror.partialErrorsByItemID is always nil or an empty list. Any suggests on how to unpack the error and get to the underlying .quotaExceeded? class SyncMonitor { /// Where we store Combine cancellables for publishers we're listening to, e.g. NSPersistentCloudKitContainer's notifications. fileprivate var disposables = Set() init() { NotificationCenter.default.publisher(for: NSPersistentCloudKitContainer.eventChangedNotification) .sink(receiveValue: { notification in print(notification: (notification)) if let cloudEvent = notification.userInfo?[NSPersistentCloudKitContainer.eventNotificationUserInfoKey] as? NSPersistentCloudKitContainer.Event { // NSPersistentCloudKitContainer sends a notification when an event starts, and another when it // ends. If it has
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags:
Assume the public database contains 10,000+ Locations from which a User would select a few as favorites How large are these locations? For example 10k CLLocation objects is a trivially small dataset for CoreData to manage. It could be downloaded in seconds or minutes and queried extremely efficiently in local storage with indexed fields or via Spotlight. Sending out a CKQueryOperation for each search requires network and unnecessarily drains a customers battery. NSPersistentCloudKitContainer supports millions of records as long as they fit in local storage. Another approach is to simply ship the locations with your application in a CoreData store that's part of your application bundle and added as a read-only store to the container.
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags:
I've built an app and got it working nicely with CoreData, and now I want to integrate it with CloudKit. I have made some minor changes to my code (namely updating NSPersistentContainer to NSPersistentCloudKitContainer and CloudKit works - I can see records appearing in the iCloud dashboard and I can modify records from the iCloud dashboard and the changes reflect on my device. Great. However, if I disable iCloud syncing via Settings on my device (without force-quitting my app) I notice a couple of things: When switching back to my app if I try and edit an entity I sometimes get an app crash If I quit and reload the app all my data has disappeared from my device (it still remains in iCloud). Is this expected behaviour? Ideally, what I would like, is that the data persists locally if a user has added records but then later decides to disable iCloud syncing on the app. Here's my code in case I've done anything funky with the implantation. It feels pretty simple, but maybe that's the problem. CoreDataMa