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.

CloudKit Documentation

Posts under CloudKit tag

245 Posts
Sort by:
Post not yet marked as solved
2 Replies
176 Views
I use UserDefaults to store a variety of user data / preferences. Recently, I have started getting somewhat frequent complaints from users that their settings have been reset. There doesn't appear to be a rhyme or reason to the issue (some users have all of their data reset just once, while others are seeing that one of their settings resets very frequently). I haven't been able to pinpoint what the root cause is, but I figure that it must have something to do with UserDefaults (either all of it or only certain keys) somehow getting erased. As I figure out the root cause, I figure that a good solution in the meantime is to backup UserDefaults in some way (e.g. perhaps to iCloud?). Is there a standard / best-practice way of doing this?
Posted Last updated
.
Post not yet marked as solved
5 Replies
149 Views
I have an app that relies on CloudKit notifications for a core feature, but for about a week now the app is not receiving any CloudKit notifications. This follows a week in which I received "status 500" errors from CloudKit and my app was rendered useless. Those errors mysteriously stopped happening, but my app is still hindered by the lack of CloudKit notifications. I have not gotten any response from Apple on this, despite several attempts through various channels. It's not tenable to build apps that users rely on based on a platform that is so unreliable, and for which support is essentially nonexistent. To any CloudKit developers reading this: Please follow up with me so that I can resolve these issues for my users.
Posted Last updated
.
Post not yet marked as solved
0 Replies
129 Views
Hello, we are planning to migrate an app that uses iCloud documents to store some documents that the user can upload/download and modify. In the official overview of App Transfer here, there are information related to CloudKit Containers and KVS but nothing related to iCloud Documents. The content of iCloud Documents is accessed using FileManager.default.url(forUbiquityContainerIdentifier: containerID) where the containerID has the form iCloud.com.things.things, even if in the official documentation it is written that the identifier must be prefixed with the Team ID. With this ID the storage works properly and we never experienced problems. Do you know if migrating an app with this functionality can be problematic? Do you know if the Team ID is somehow used even if not explicitly passed in the call to the function? Thank you and have a nice day!
Posted
by Svan-bsp.
Last updated
.
Post marked as solved
1 Replies
156 Views
Since a couple days ago, CloudKit database queries in my app and on the CloudKit dashboard fail with the error "request failed with http status code 500". Nothing significant changed in the app recently, and it has otherwise worked well most of the time for more than a year, although CloudKit seems to have outages somewhat frequently. My app is mostly unusable without access to the CloudKit database, so this is a critical issue. I have also filed a Feedback report (FB13709321) on this issue.
Posted Last updated
.
Post not yet marked as solved
1 Replies
183 Views
I recently discovered the new documentation for enabling CloudKit sync with SwiftData. A key step I was missing in my previous setup was this step: Initialize the CloudKit development schema. When I run this though, I get Core Data errors in my log... CoreData: Unsupported attribute type I've noticed that it seems to be preventing adding fields for my model properties that are Codable structs. I've been able to add Codable structs to my SwiftData models synced with CloudKit before. But using Core Data to initialize the CloudKit schema like the documentation suggests just doesn't work. Is there some other way around this? I'm about to just give up on CloudKit sync altogether. I need this to work because I'm trying to add some new fields and populate the fields with data based on existing data during the migration, but this seems to be preventing migration completely. If I don't initialize the schema, I get different errors and the ModelContainer won't initialize at all.
Posted
by jonduenas.
Last updated
.
Post marked as solved
2 Replies
163 Views
Some of my users are reporting an inability to sync via CloudKit between devices. I have not seen it on any of my devices, but one user got me some console logs that are showing the following error: <CKError 0x600000a0f840: "Partial Failure" (2/1011); "Failed to modify some records"; uuid = EDC7B3E3-02F8-43B7-83B6-22D17EF0442A; container ID = "iCloud.cribaudo.iphemeris"; partial errors: { C611E11F-3DC0-484C-8FC1-23473062D9D0:(com.apple.coredata.cloudkit.zone:defaultOwner) = <CKError 0x600000a04660: "Invalid Arguments" (12/2006); server message = "Cannot create or modify field 'CD_nameFirstChar' in record 'CD_Charts' in production schema"; op = D83EF1F7DD772042; uuid = EDC7B3E3-02F8-43B7-83B6-22D17EF0442A> I do not understand this: The field CD_nameFirstChar was added to the data model in the version 15. Automatic Migration is enabled. The CloudKit Console says the Private Database Container being used by my App is deployed to production. The entity CD_Charts (I only have one) that is deployed to production shows that field as present (CD_nameFirstChar). Why would this user be getting this error? As far as I can see they are running a version where migration to Model 15 should have been triggered at some point in the past. If somehow something went wrong with their migration, how would I fix it? Any thoughts / ideas are appreciated. One thing I should add is that the migration from Model 14 to 15 was not lightweight. I did use: @interface ModelMigration14to15 : NSEntityMigrationPolicy -(NSString *)nameFirstChar:(NSString *)name; @end And I used a MapModel14to15 which used the above function to set the value of nameFirstChar. The Value Expression for that attribute is: FUNCTION($entityPolicy,` "nameFirstChar:" , $source.name) from the above mentioned NSEntityMigrationPolicy class. This worked ok on all my devices and apparently on some user devices. This issues seems to effect only a small subset of my users but not all? So I am at a loss to understand why this would happen or how to fix it.
Posted
by cliffr.
Last updated
.
Post marked as solved
3 Replies
383 Views
I've been scratching my head on this one. Out of the blue, part of my 'synchronization' mechanism that copies 'favorites' from device to device has stopped working. A user can save a favorite location and it will propagate to all of their other devices, or repopulate after an uninstall and reinstall. My code in the space hasn't changed for months and I haven't made any schema changes to this type either. Last night I noticed the process wasn't working anymore. My CKQueryOperation result completion is returning this error: &lt;CKError 0x2818a16b0: "Server Rejected Request" (15/2001); "Request failed with http status code 500"; uuid = 2CA523A6-8F39-4538-98AF-E9B7D6CACF73&gt; What is telling to me is that the CloudKit Console also fails with an internal error when I try to query this type in MY private database for two different accounts. I can query another type in the private database but this one won't work for two of the Apple ID's I have tried. Also interesting, if I query this type in the PUBLIC database, even though this type is only saved to the private database, that operation succeeds just fine. I don't want to burn a DTS ticket for a server issue. FB13543186 - CloudKit: Receiving 500 when performing a query operation on the private database CloudKit status page is green on the developer site as of this morning.
Posted
by edorphy.
Last updated
.
Post not yet marked as solved
0 Replies
138 Views
Sending push notifications does not work. The notification does not arrive, the loading hangs endlessly. Yesterday everything was fine with push notifications, but today they stopped coming. Has anyone come across what could be the problem?
Posted Last updated
.
Post not yet marked as solved
2 Replies
156 Views
Hey, I'm currently working on adding CloudKit support to the GRDB SQLite database in my app. CKSyncEngine, though still a bit tricky to wrap your head around, is amazing! I have most of the basic setup implemented and some very easy cases already work, which is really exciting! However, I do have some questions regarding data consistency across devices. I'm not sure though, that these questions are actually "correct" to ask. Maybe my entire approach is inherently flawed. Say we add two records to the pending changes of the sync engine: // I'm simplifying CKRecord.ID to be a String here syncEngine.state.add(pendingRecordZoneChanges: [.saveRecord("1"), .saveRecord("2")] Let's also say that both records are tightly connected. For example, they could be in a one-to-one relationship and must always be added to the database together because the app relies on the existence of either none or both. After that call, at some later point, the system will call the sync engine's delegate nextRecordZoneChangeBatch(_:syncEngine:) for us to batch the changes together to send to iCloud. First question: Can we guarantee that records "1" and "2" always land in the exact same batch, and are never separated? Looking at the example code, there are two line that worry me a bit: // (Sample project: `SyncedDatabase.swift, lines 132-133`) let scope = context.options.scope let changes = syncEngine.state.pendingRecordZoneChanges.filter { scope.contains($0) } The scope could lead to one of the two records being filtered out. However, my assumption is that the scope will always be .all when the system calls it from an automatically managed schedule, and only differs when you manually specify a different value through calling syncEngine.sendChanges(_:). Is that correct? Now back to the example. Say we successfully batched records "1" and "2" together and the changes have been sent to iCloud. Awesome! What happens next? Other connected devices will, at some point, fetch those changes and apply them to their respective local databases. Second question: Can we guarantee that iCloud sends the exact same batches from earlier to other devices and does not create new batches from all the changes? I'm worried that iCloud might take all stored changes and "re-batch" them for whatever reason (efficiency, for example). Because that could cause records "1" and "2" to be separated into different batches. A second device could end up receiving "1" and, for at least some period of time, will not receive "2", which would be an "illegal" state of the data. I'd appreciate any help or clarification on this :) Thanks a lot!
Posted
by Quantm.
Last updated
.
Post not yet marked as solved
0 Replies
175 Views
I currently have a production app that uses CloudKit I always struggle with testing the data within the development container and I was wondering if someone could share their current workflow. What is your current workflow when testing apps that use CloudKit, do you use your regular Apple User account for testing, or you use separate account? My concern is because I use my production app on a daily basis using my regular Apple user account, so I would like to keep the production iCloud data intact. In other words, I have my app on my phone with real data and now I need to test the app because there are some CloudKit syncing issues so I have the following questions. Can I connect my phone with production data to Xcode and use my regular Apple account for testing purposes? Will I be able to see the testing data in the CloudKit console? Will the production data merge with the testing data? I actually created a second Apple account thinking that I could use it for testing but logging off and logging back on to iCloud in your iPhone it's a pain, is this really what needs to be done? Any ideas would be greatly appreciated. Thanks
Posted
by fsdolphin.
Last updated
.
Post not yet marked as solved
2 Replies
194 Views
Questions about isExcludedFromBackup option and device migration I posted a similar question a year ago, but I still haven't found a solution that I like, so I'm leaving this question. If anyone knows how, please let me know. In our app, we set the isExcludedFromBackup option to true so that files currently in the Documents path are not backed up to iCloud. In the current situation, I am just curious as to whether the files of our app can be backed up in the two situations below. (with isExcludedFromBackup option set to true ) Migrate iPhone to new iPhone Backup and restore the entire device to iTunes If you set the isExcludedFromBackup option to true in the file, iCloud backup will not be possible, and the app's internal files will not be copied even in the two situations mentioned above. Is there an option or method in the app's internal code to prevent automatic backup only to iCloud and allow files to be copied or synchronized in the above two situations?
Posted Last updated
.
Post not yet marked as solved
1 Replies
177 Views
Hello everyone, How do I need to handle the delete with the relationship deny? When I delete a model that still has a reference to another model, it deletes it from the UI. But when I re-run the simulator, it's back again. Does someone have a hint for me? How is it possible to ensure the uniqueness of the entries? Because I saw that the Attribute unique can't be used with CloudKit.
Posted
by iRIG.
Last updated
.
Post not yet marked as solved
0 Replies
169 Views
My app is currently on the app store for IOS, iPadOS and MacOS. I have created a version for Apple TV but cannot get it to save to iCloud. Is there anyone who can help me get my app to save to iCloud for the Apple TV?
Posted Last updated
.
Post not yet marked as solved
2 Replies
197 Views
I am trying to create a specialised photo sharing social network using CloudKit alone. The app will never need to be non iOS, so on the surface Cloudkit has seemed like a perfect backend. However, I've found at random but semi frequent times, the loading of CKAssets from records can be very slow. For example, at normal times, all of the assets can load in a second or less. However at other times, it can take from 5 to 15 seconds. This is on a public database using a fetch operation where I already have the record IDs. Here is my code that performs that: mainDatabase.fetch(withRecordIDs: recordIDS, desiredKeys: ["image"]) { results in var recordsToReturn: [CKRecord] = [] switch results { case .success(let success): for (_, result) in success { switch result { case .success(let record): // If the result is success, append the record to the successfulRecords array recordsToReturn.append(record) break case .failure(_): break } } completion(.success(recordsToReturn)) case .failure(let failure): completion(.failure(failure)) } } } Of note, I have also tried using a database operation at set the qualityOfService to userInitiated, which has had the same noticeable load times. I have also tested this on different devices, on different networks (both cellular & different WiFi connections) and found also the same noticeable load times at random occurrences. Therefore, what I am trying to find out: Is this an expected behaviour from using CloudKit? Is there a much better way to load CKAssets that would drastically help this load time issue? Is CloudKit even a viable option for this kind of app, or is it not designed for this type of app? What alternative approaches could be taken? (Eg. store assets in AWS...) Would truly appreciate any feedback & guidance on this issue.
Posted
by sknc.
Last updated
.
Post marked as solved
1 Replies
287 Views
Hello everyone, I followed this (https://www.hackingwithswift.com/quick-start/swiftdata/how-to-sync-swiftdata-with-icloud) guide from Paul Hudson on how to sync swiftdata with iCloud. I tried it on my device directly and it worked exactly as I would expect. Now I tried the same version of the app on another device installed through TestFlight external tester group. It no longer works. When deleting the app, the alert reads "Deleting this app will also delete its data, but any documents or data will be stored in iCloud will not be deleted" so the app should have said something in iCloud. When looking in Settings -> Your Name -> iCloud -> Manage Account Storage, on the working device I can see around 300 KB saved in iCloud, on the other device my app is not listed. Both have a fast and working internet connection, almost fully charged, low data mode turned off, running 17.4.1, Background modes enabled, Mobile data enabled, more than enough unused iCloud storage and plenty of time to sync. I was streaming the logs from the Cloudkit dashboard but nothing appeared there. The data saved neither syncs to another device of the same apple id nor reappears after app removal. The model Container is initialized without any configuration, the only relationship is optional and every value has a default value. There is A LOT of log noise when launching the app and I am unable to get any meaningful information from that. I can only get the log from the device where it is working as expected. I have triple checked that it is exactly the same app version and no debug conditions anywhere. I have absolutely no idea what is causing this. Thanks for any help :)
Posted
by FPST.
Last updated
.
Post not yet marked as solved
11 Replies
6.9k Views
Any insights on how to incorporate CloudKit (or CoreData) in the WidgetKit extension? Where in the WidgetKit api do I make the asynchronous call to load the data to be available for the TimelineProvider?
Posted
by cristosv.
Last updated
.
Post not yet marked as solved
0 Replies
236 Views
Hello, I want to build an app that will allow the user to entry some health related records and be synced with the HealthKit. Any record that is in the HealthKit is stored locally on the device. I find it conceptually unsure if I should be storing the HealthKit records in the SwiftData to make the user records available across the iCloud synced devices. Should I read the HealthKit record, make a copy of it (including it's ID) on my app's data in SwiftData? How the syncing should be done the right way? thanks.
Posted Last updated
.
Post marked as solved
1 Replies
247 Views
I am developing a SwiftData application using CloudKit. I have been playing with the app for a while and populated the database. Recently I decided to change the type of an attribute. So I reseted the scheme in CloudKit Console to the production one, which actually is empty for now, so I restart from scratch. Unfortunatly, the locally cached database on my Mac is using the old schema and my app fails loading the ModelContainer because of the type incompatibilities. I would like to delete the locally cached database but I haven't a clue of where it can be. I do not want to go through a migration plan for that. Does someone know where can I find it ? Chris tof
Posted
by Chris Tof.
Last updated
.
Post marked as solved
4 Replies
600 Views
My app has been in the App Store a few months. In that time I've added a few updates to my SwiftData schema using a MigrationPlan, and things were seemingly going ok. But then I decided to add CloudKit syncing. I needed to modify my models to be compatible. So, I added another migration stage for it, changed the properties as needed (making things optional or adding default values, etc.). In my tests, everything seemed to work smoothly updating from the previous version to the new version with CloudKit. So I released it to my users. But, that's when I started to see the crashes and error reports come in. I think I've narrowed it down to when users update from older versions of the app. I was finally able to reproduce this on my end, and Core Data is throwing an error when loading the ModelContainer saying "CloudKit integration requires that all attributes be optional, or have a default value set." Even though I did this in the latest schema. It’s like it’s trying to load CloudKit before performing the schema migration, and since it can’t, it just fails and won’t load anything. I’m kinda at a loss how to recover from this for these users other than tell them to delete their app and restart, but obviously they’ll lose their data that way. The only other idea I have is to setup some older builds on TestFlight and direct them to update to those first, then update to the newest production version and hope that solves it. Any other ideas? And what can I do to prevent this for future users who maybe reinstall the app from an older version too? There's nothing special about my code for loading the ModelContainer. Just a basic: let container = try ModelContainer( for: Foo.self, Bar.self, migrationPlan: SchemaMigration.self, configurations: ModelConfiguration(cloudKitDatabase: .automatic) )
Posted
by jonduenas.
Last updated
.
Post not yet marked as solved
0 Replies
164 Views
Hi Forum, I am wondering how I can filter the data retrieving from CloudKit with SwiftData and using the #Predicate macro? I always get this error message: Thread 1: Fatal error: Predicate does not support keypaths with multiple components Does someone know how to add two predicates and use CloudKit? Thanks in advance 😊
Posted
by 14slash12.
Last updated
.