CloudKit

RSS for tag

Store 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

Preferences on Simulator crash when accessing iCloud settings
As per the title, as soon as I try to open iCloud settings on the Simulator, a black screen appears and the Preferences app crashes (and a crash report shows up shortly thereafter). This is an issue in all of Xcode 17.0.0, XCode 17.0.1 and the Xcode 17.1 beta. I've tried all the simulator models from the SE to the 15. I think this may be something to do with the following two pop-ups that keep showing up on the Simulator but don't actually do anything when tapped: one says to accept new iCloud T&Cs. When I tap on it, nothing happens (and I can't find new T&Cs to accept in the web browser); and one that prompts me to re-enter the Apple ID password. When I input the password and confirm, nothing happens. This is causing major issues for testing a couple of my apps because Simulator sometimes radomly thinks that the user isn't signed into iCloud when they, in fact, are. For example, I've been getting the following error from GameKit: 'The requested operation could not be completed because you are not signed in to iCloud..' (the same function that throws the error does confim that the user is signed in just before throwing). I'd be very grateful for any thoughts. Been stuck on this for well over a week now...I've found various threads about the wider Preferences app crashing (and this being fixed in the latest beta) but nothing on the specific issue I'm having.
1
0
611
Oct ’23
Data Migration from Development to Production in CloudKit for TestFlight Testing
I've developed an app utilizing substantial data uploaded to a CloudKit record in the development environment. Having deployed the Record Type schema to production and released a TestFlight version for testing, how can I transfer the data from the development to the production environment, or upload the data directly to the production environment? This is crucial as TestFlight testers can only access data from the production environment.
0
0
384
Oct ’23
Increased number of CKErrorServerRejectedRequest
Hi, I have a CloudKit based app in production on the App Store for the past 5 years. One feature in the app downloads a lot of records, over a few different recordTypes, from a user's private database using an array of CKQueryOperations (using an NSOperationQueue). This has been working fine for the past few years, and even now works fine for most users, but an increasing number of users are seeing one of the operations in the array fail for CKErrorServerRejectedRequest. This has been happening over a few weeks now, and the customer support is getting burdensome. Asking the user to repeat the feature sometimes fails, and sometimes succeeds, with no obvious reason. This is also happening for operations for recordTypes where there aren't any records in the private database, as well as for recordTypes where there are hundreds of records. I haven't made any changes over the past year that directly impacts this process. Why would this sudden increase be happening and how do I go about analyzing and fixing it? Also, my current code handles this by cancelling all the operations in the operation queue, because the comment I saw in CKError.h for this error says "This is a non-recoverable error". I'm not sure I completely understand what that means ... is the operation non-recoverable (and hence I should retry by creating a new operation), or is the user's private database corrupted, or what? Would be great if I could get some insight / suggestions.
2
0
480
Oct ’23
CloudKit and Background tasks
Hi. Didn't find the answer in the documentation. Are CloudKit procedures executables in background tasks ? I'm trying to do : "[privateDatabase fetchRecordWithID:myMasterRecordID completionHandler:^(CKRecord *myMasterRecord, NSError *error) { ... }]" but it returns a record only when the app is active. In background task, it does nothing and waits until app is active. Thanks for you answer. Best Claude
1
0
740
Oct ’23
Designing a Word of the Day App: Balancing Local Word Data with Cloud-Based Learning Records"
I have a "Word of the Day" application with a CoreData database containing approximately 14,000 word entities. These entities have attributes like frequency (indicating how often a word appears in some corpus), definition, and pronunciation. Currently, this information is stored locally. I want to add a feature that allows users to store their learning data about these words. For example, users should be able to mark words with a rating of 1, 2, or 3 to indicate their degree of familiarity with the words. My ultimate goal is to display the highest-frequency word with a user familiarity rating of 1 and display it as todays word of the day. The challenge I'm facing is how to set up my app so that learning data is stored in the cloud while the word information remains stored locally. I've seen that you can create different configurations and have one connected to CloudKit, but this approach may make it difficult to write queries that combine information from both the Word entity and the LearningData entity. I'm looking for suggestions on how to address this issue effectively.
0
0
280
Oct ’23
In CloudKit, how do I check whether the user of an app is the share-sender or the share-receiver?
In other words, I’m trying to setup sharing in my app using Core Data with CloudKit. Basically the user can share their list of CloudKit records with other users of the app. Should that other user accept that share from that share-sender, the share-receiver can then sees the sender’s list of records. This part works as I need it to. This is fine. As well, the app is largely being written in SwiftUI. However, what I also need is to give the user the ability to see only their own records, or to set one of their records to private. I think I can figure this logic out, but I’m still not sure of how to filter the sender versus receiver of that share, AKA owner vs participant. I’ve tried several things to figure this out, and I keep coming up empty. I feel like there’s a good way to do this, however what I’ve done always has issues. Can someone please describe the best way to do this?
0
0
399
Oct ’23
Receiving NSPersistentStoreRemoteChange notification when app is closed
I use NSPersistentCloudKitContainer to fetch/sync data across multiple devices with the same iCloud account. /// ... container = NSPersistentCloudKitContainer(name: containerName) let description = container.persistentStoreDescriptions.first description?.setOption( true as NSNumber, forKey: NSPersistentStoreRemoteChangeNotificationPostOptionKey) description?.setOption( true as NSNumber, forKey: NSPersistentHistoryTrackingKey) let viewContext = container.viewContext viewContext.automaticallyMergesChangesFromParent = true viewContext.mergePolicy = NSMergePolicy.mergeByPropertyObjectTrump NotificationCenter.default.addObserver( forName: .NSPersistentStoreRemoteChange, object: container.persistentStoreCoordinator, queue: .main ) { _ in Task { @MainActor [weak self] in // fetch new data and update widgets with it // ... viewContext.fetch ... // WidgetCenter.shared.reloadAllTimelines() } } } /// ... Everything works fine when my app in the foreground. How can I achieve the same when my app is closed/ in the background? I know that CloudKit can send silent push notification which can wake up my app but I've never seen the implementation of it using CoreData NSPersistentCloudKitContainer
0
0
426
Oct ’23
Fix CloudKit container permissions
I've been using CloudKit for my app recently and I'm trying to add support for a WatchOS app and I've enabled iCloud in capabilities and ticked the container I want to use but I get this error. CoreData: error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate recoverFromPartialError:forStore:inMonitor:]block_invoke(1943): <NSCloudKitMirroringDelegate: 0x282430000>: Found unknown error as part of a partial failure: <CKError 0x28112d500: "Permission Failure" (10/2007); server message = "Invalid bundle ID for container"; uuid = ; container ID = "iCloud.Appname"> I tried creating a new container which worked for both the watch app and iOS app however I would like to use my original container since it has my old data
4
1
5.1k
Oct ’23
How to fix NSCloudKitMirroringDelegate unhandled exception after faulty model change
I have a complex data model in development mode, with a large amount of data, using CoreData with CloudKit sync. All worked fine, syncing from a Mac to an iPad Pro, until I made some unwise changes to the model and a couple of relationships. I should have known, but was hurrying and not thinking clearly. The App is not on the App Store: it's for my own use. Records are now not synced to CloudKit: _error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _importFinishedWithResult:importer:]- (1371): <PFCloudKitImporter: 0x6000005d8080>: Import failed with error: Error Domain=NSCocoaErrorDomain Code=134421 "Import failed because applying the accumulated changes hit an unhandled exception." UserInfo={NSLocalizedFailureReason=Import failed because applying the accumulated changes hit an unhandled exception., NSUnderlyingException=* -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[0]}_** It seems that there's a queue of faulty (non-matching) updates, which I can find no way of purging. Perhaps I could disconnect the CloudKit syncing in the app, use the CloudKit console to reset the development environment, then reconnect CloudKit syncing in the app - but would that invoke a repopulation of the CloudKit data, or cause a deletion of all CoreData data? I can, with a few days' work, reimport all of the data - but that would, I assume, need a newly named app so as to create a new CloudKit container. Any thoughts/solutions would be appreciated. Regards, Michaela
4
0
753
Oct ’23
CloudKit causes SwiftUI Menu to be dismissed
After updating to iOS 17 and Xcode 15 I noticed that menus on my app get automatically dismissed while CloudKit is syncing data right after opening the app. I know it's CloudKit because this issue doesn't happen when I launch the app in Airplane Mode. It looks like CloudKit causes something to change (even when there are no data changes since the last usage), which causes the UI to refresh. This refresh causes the menus to be dismissed. This is frustrating because users have to tap a button two or three times before being able to interact with the menu showed by the button. I'm attaching a screen recording that shows the issue: https://youtube.com/shorts/Wl9gP2HLktE I open the app and tap the "+" icon, which shows the menu. The menu is quickly dismissed. I tap the "+" icon again, and the menu is shown for a millisecond, and is dismissed again. I tap the "+" button once again. This time the menu is shown and stays there because CloudKit has finished its initial sync process. Note that this didn't happened on iOS 16 / Xcode 14, so something must have changed to cause this issue. Is there something I need to update on my code to fix this issue, or is it a bug in the OS or frameworks that will be fixed in a future update?
2
1
582
Oct ’23
Swiftdata: CloudKit integration requires that all attributes be optional, or have a default value set
Unfortunately I can not get swiftdata to work for me. I created a brand new project in Xcode, modified no code and the program fails with this error. Only thing I did was add an iCloud container. The default code that you are given for a swiftadata object is: @Model final class Item { var timestamp: Date init(timestamp: Date) { self.timestamp = timestamp } } Xcode wants that values in this model to ether be optional or have a default value. I thought this was a bug that had been fixed, but I am on the latest Xcode. I am not sure how to proceed. If the default code Xcode gives you won't compile, how am I able to code my own?
1
0
520
Oct ’23
"Failed to set up CloudKit integration" in TestFlight build
I'm building a macOS + iOS SwiftUI app using Xcode 14.1b3 on a Mac running macOS 13.b11. The app uses Core Data + CloudKit. With development builds, CloudKit integration works on the Mac app and the iOS app. Existing records are fetched from iCloud, and new records are uploaded to iCloud. Everybody's happy. With TestFlight builds, the iOS app has no problems. But CloudKit integration isn't working in the Mac app at all. No existing records are fetched, no new records are uploaded. In the Console, I see this message: error: CoreData+CloudKit: Failed to set up CloudKit integration for store: <NSSQLCore: 0x1324079e0> (URL: <local file url>) Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.cloudd was invalidated: failed at lookup with error 159 - Sandbox restriction." UserInfo={NSDebugDescription=The connection to service named com.apple.cloudd was invalidated: failed at lookup with error 159 - Sandbox restriction.} I thought it might be that I was missing the com.apple.security.network.client entitlement, but adding that didn't help. Any suggestions what I might be missing? (It's my first sandboxed Mac app, so it might be really obvious to anyone but me.)
2
0
2.1k
Oct ’23
CloudKit stopped syncing on WatchOS
Hey, I have an iOS/watchOS application that has been in the App Store since the beginning of last year (for reference: https://endsplus.com). Part of the functionality includes: Create a Fixture on the Phone Create Fixture on iOs Fixture is saved to Core Data Core Data syncs with CloudKit WatchOs pulls down the record, updating a table of the same name I can show the Fixtures on the Watch. Track a game on the Watch and then save it. Create a Game on WatchOS Game is saved to Core Data Core Data syncs with CloudKit iOS pulls down the record, updating a table of the same name I can show the games on the phone. For reasons I am unable to work out syncing of core data tables between the phone and the watch has stopped working. I know that the iOS coredata/cloudkit functionality is working as I can create a record on my physical phone, then run a simulator and log in with the same iCloud account and see the record. But the functionality has stopped working for watchOS. I have added a new table to the Watch side that is not syncing to the Phone, but an existing table (Fixture) that has been working has also stopped syncing between the phone and the watch. None of my Persistence/Core Data code has changed. My new table is associated with a Cloud Store, the same as my old table is. What options are they available to me to try and debug this. The watchOs simulator doesn't seem to work with CloudKit, telling me it is not signed in. I've tried looking at the CloudKit database logs, but obviously for security I can't see the data, but I can't see any errors from the watch. I've uninstalled and re-installed the application (on the phone and the watch) numerous times, but that isn't working. Does anyone have any ideas? Thanks
4
0
643
Oct ’23
CloudKit subscription only works when operation is performed in CloudKit Dashboard and not when done programmatically
I have set up a CKQuerySubscription in the default zone that sends a Push notification every time a record meeting the given criteria is deleted in a public CloudKit database. However, the notification is only sent when I delete the record via the CloudKit Dashboard and not when I delete a record programmatically. I have tried creating a record with User A on a device and then having that record deleted by User B on a different device but it doesn't result in User A getting notified. Additionally, the only case where the notification gets sent is on a device that is signed in with the iCloud account that I use for CloudKit Console. In other words, when I delete a record that was created by a user with a different iCloud account than the one I use for the CloudKit Console the notification does not get sent to that device - it's only successful on the device with the CloudKit Console iCloud account. What I expect to happen is the subscription to fire when the record in question is deleted regardless of how and by whom it is deleted. Is this possible? Any help would be appreciated.
1
1
523
Oct ’23
CKQueryOperation returns new cursor, but no results, eventually rejects requests
In my app, I am using CloudKit and one thing I need to do is to query all records of a certain record type. I am creating a CKQueryOperation with the record type I am interested in, leaving the rest to the defaults basically (resultsLimit, desiredKeys, qualityOfService etc). Most times, the app does not return any results at all, but does return a queryCursor, indicating there are more results to fetch. So I add a new CKQueryOperation with a CKQuery created with the returned queryCursor. But the same thing happens again (most of the times) - no results (or maybe a single result) and a new queryCursor. This goes on and on until either all results are returned (which usually is not the case) or CloudKit errors out with "Server rejected the request" (perhaps for rate-limiting reasons?). The same behaviour can be observed when using the CloudKit web API, and it doesn't seem to matter what values I set for resultsLimit, desiredKeys, qualityOfService etc... So, what am I doing wrong? How can I query all records of a record type without errors?
2
0
366
Oct ’23
Cloudkit discrepancy between tvOS and iOS
Hi, I have an application that would require sync between iOS and tvOS devices. The cloudkit saving/loading code is exactly the same for both platforms but the data does not seems to be synchronised between the 2 devices. Even when I tried to output the data that was updated, iOS only show the data: CKRecord: 0x123456789> whereas tvOS showed more details like: CKRecord: 0x987654321; recordType=SavedGame, recordID=save_file.dat:(_defaultZone:__defaultOwner__), recordChangeTag=ln2rxsh8, values={ data = "<CKAsset: ??; referenceSignature={length = 21, bytes = 0x??????}, path=~/Library/Caches/save_file.dat, size=8005, UUID=?????, signature={length = 21, bytes = 0x?????????}, wrappedAssetKey=<24 bytes>>"; *I replaced the actual data information with ???? Although both have the exact same uploading code, I am having difficulty synchronising between both devices. Not sure what other settings did I missed out to ensure that both can be synchronised properly. Both are using the same iCloud account and apple account. Would appreciate any help. Thank you.
0
0
346
Oct ’23