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

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
335
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
611
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
491
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
503
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
407
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
389
Oct ’23
SwiftData project segfaults when I enabled iCloud sync
The crash is at do { retval = try ModelContainer(for: schema, configurations: [modelConfiguration]) } catch { fatalError("Could not create ModelContainer: \(error)") } When I first set it up, it complained (at run-time) about a lot of issues, mainly items not being optional and I apparently had a couple of @Attribute(.unique)s left. After I got rid of all of those, however, I get the crash there. I assume this is an obvious thing that I am doing wrong, but I can't figure it out.
3
0
508
Nov ’23
CloudKit Console - Internal Error during Query Records
Issue: I'm experiencing intermittent CloudKit Console 'Internal Error' when performing simple queries on a Private database. I am experiencing this issue with multiple CloudKit databases. In all instances, the issue is intermittent. Steps to Replicate in the CloudKit Console: Select a Database Select Records Select Private Database Select Custom Zone Select Record Type Select Query Records IF the records populate, click 'Query Records' again until Internal Error occurs. Expected Results: A list of records Actual Results: 'Internal Error' (see screenshot below) Additional Info: Starting last month, I started receiving CKCloudKit Error 15 when attempting to sync data from a private CloudKit database. My query code has not changed for a few years now with no previous issues. I believe these errors are the 'same' and on the Apple Server side. Is anyone else experiencing this issue? Any help would be greatly appreciated. Thank you.
3
2
659
Dec ’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
274
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
467
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
376
Oct ’23
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
593
Oct ’23
Transitioning Data from Development to Production Environment in CloudKit
In order to load your data into the production environment in Apple CloudKit, follow the steps below: Deploy Your Schema: Initially, deploy your schema to the production environment using the recommended approach provided by Apple. Prepare for TestFlight: Retain all the codes and views utilized previously for uploading data to the development environment. Deploy your app to TestFlight. TestFlight Approval and Data Transition: Upon receiving approval and ensuring the functionality on TestFlight, the same codes and views that were used to upload data to the CloudKit records in the development environment will now point to the production environment. Consequently, all the data will be uploaded to the production environment, facilitating a smooth transition. Post this process, your app on TestFlight will interact with the data in the production environment of CloudKit, ensuring consistency and enabling effective testing. This method ensures a seamless transition of data from the development environment to the production environment, aligning with the operational flow of CloudKit and TestFlight.
1
0
440
Oct ’23
iCloud 503 error
Hi, our app is down since a few hours as we can not fetch data from iCloud CKErrorDescription = "Request failed with http status code 503"; CKHTTPStatus = 503; CKRetryAfter = 60; NSDebugDescription = "CKInternalErrorDomain: 2022"; NSLocalizedDescription = "Request failed with http status code 503"; NSUnderlyingError = "<CKError 0x2806784e0: "Service Unavailable" (2022); "Request failed with http status code 503"; uuid = UID; Retry after 60.0 seconds>"; RequestUUID = "UID"; } came out of nowhere.
1
0
317
Oct ’23
Core Data error: 'cannot use an attribute type of "Composite"' when "Used with CloudKit" checked
Hello, I'm running into an odd error. I'm trying to add a composite attribute called period to a Core Data Entity named Report, but I'm getting a compile-time error that points to my xcdatamodel file: Report.period cannot use an attribute type of "Composite". In my model configuration I have "Used with CloudKit" box checked. If I uncheck this box, the error goes away and everything builds fine. But the documentation for NSCompositeAttributeDescription says: You may use composite attributes anywhere you use standard attributes, including lightweight migrations and CloudKit, through NSPersistentCloudKitContainer. So it seems like I should be able to use composite attributes in Core Data with CloudKit syncing enabled. What am I missing here? Is this a bug, or am I doing something wrong?
2
0
328
Oct ’23
Migrating from CoreData to SwiftData causes crashes on Watch app
I'm working on migrating my app from using CoreData to SwiftData. The swift data code generated by Xcode works correctly for the iOS and Mac Catalyst targets but it is causing a crash for the WatchOS target. It gives me this message **Fatal error: Application must register a ValueTransformer for NSSecureUnarchiveFromDataTransformer ** This attribute is the only one with a .transformable option. @Attribute(.transformable(by: "NSSecureUnarchiveFromDataTransformer")) public var linkedEntities: [UUID] = [] Changing the string NSSecureUnarchiveFromDataTransformer to NSValueTransformerName.secureUnarchiveFromDataTransformerName.rawValue causes a generic crash with no error message. The app has CloudKit integration as well (not sure if relevant). Does anyone have a similar issue and can help me on what to do here?
2
0
612
Nov ’23