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

325 results found
Sort by:
Post not yet marked as solved
19 Views

Cloudkit - coredatat - duplicate row on tableview

I have switch my database with cloudkit function. I have two iPads : after few tests, the database was synchronize between the two devices. But after checking all data, in one view, there are duplicate rows, : with the same UUID !!! This error is not present in all views, just few ones...and I do only fetch for the moment, no create data in debug the fetch show duplicate values, why I do not understand this behavior because on my database before using two ipad, I had only one Record for a element not twice??? myarray = try moc.fetch(ReferencesRequest) same record present twice in the array after fetch
Asked
by docgg.
Last updated
.
Post marked as solved
37 Views

Cloudkit - Coredata and multiples database

Today, I'm working without cloudkit (all data are in a local Coredata), with one database on my Xcode project but with 2 containers on app.delegate : one for a test environment : with storeURL ---> test.sqlite one for a production environment : with storeURL --> production.sqlite Everything is ok, the test data, is really separate from production data. Now, I try to use cloudkit functions : I change NSPersistentContainer to NSPersistentCloudKitContainer it's working and I could use data on 2 iPads. BUT if I switch the test to the prod, now the data from test environnement is duplicate on the production environnement. what mistake am I making? How could I use my two storeURL with cloudkit coredata? Thanx for your help.
Asked
by docgg.
Last updated
.
Post not yet marked as solved
1.5k Views

CloudKit watchOS 6 silent notification problem

Hello,I watch the WWDC video regarding keep iPhone and independent watch app (watchos 6) in sync. So I have made a simple cloudkit subscription on the Apple Watch on a record (watch os 6). 1) On the iPhone I modify the record, but when the iPhone is unlocked the notification is never send from cloudkit to the Apple Watch.If I modify the record directly on the cloudkit dashboard and2a) the iPhone is locked, then the silent notification is sent to the watch.2b) the iPhone is unlocked, then it is show directly on the iPhone. For user visible notification this behavior make sense, but in case of silent notification it doesn´t, because there is no way if you change settings on the iPhone App (iPhone unlocked), that you get a push to the watch (via the cloudkit subscription). Does anybody have the same problem or any way to get this working with cloudkit?
Asked Last updated
.
Post not yet marked as solved
11k Views

How to delete container in CloudKit Dashboard?

For demo iCloud, build many containers in CloudKit Dashboard. Now i want to delete some old containers but i can't. I need help thanks.
Asked Last updated
.
Post not yet marked as solved
28 Views

Changing attribute type in a PersistentCloudKitContainer Model

I have a Multiplatform app using a PersistentCloudKitContainer Model that has a complex object graph and which is still in Development mode (including in CloudKit). An integer attribute of one of the entities needs to be changed to double, for reasons that were not obvious on first analysis of data. According to the Core Data Migration documentation , which is 10 years old, this case would not be Lightweight Migration and so I would need to create a Migration Policy and Process. Although I've only recently imported a few legacy records that set the Int attribute (now required to be Double), there are several hundred entities (imported legacy data) with a default Int value (0). Tempting though it is to just change the attribute type from Int to Double and see what happens, recreating the model and hundreds (thousands?) of records if things go wrong would be a real pain in the derriere. So, given the complexity of my model and the use of CloudKit for multi-device synching, I'm thinking I'll create a new Double attribute and reimport data into that, then when all's fine delete the original Int attribute. This way both sets of changes are Lightweight. Advice? Thoughts? Regards, Michaela
Asked Last updated
.
Post not yet marked as solved
248 Views

http status code 503

Hi, we started getting a message on some devices: "Failed to fetch the data base records. Request failed with http status code 503". It appears when we are trying to retrieve data from iCloud (when we save data to iCloud it does not appear and saves sucessfully). What could be the cause?
Asked
by dimitriev.
Last updated
.
Post not yet marked as solved
105 Views

Shared Records don't appear when app is in Production

After sharing the records through iCloud, when I run the app on Xcode I can see them, but when I run it either on TestFlight or from App Store it doesn't work. The shared records aren't fetched. This has been going on for months.
Asked
by jbowl.
Last updated
.
Post marked as solved
2.4k Views

SwiftUI App Protocol and Remote Notifications

I am trying to bring CloudKit syncing to a new SwiftUI app using the new App protocol and have not found a way to listen for remote notifications. Is this possible with the new updates to SwiftUI this year or is this currently an AppDelegate thing only?
Asked Last updated
.
Post marked as solved
3.1k Views

How to save game data to iCloud?

Hello, I'am an Unity game developer. Iam using custom Binary files to save game progress data (encoded strings, int, bool etc.). Now before I build my project/game to Xcode and upload it to the Appstore, I want the user to be able to save their progress to the iCloud so they can play on multiple devices and restore/override their game data if needed. However I can't find online a step for step guide on how to achieve this. The data that I would need to store for 1 user would probably not be more then 100 int/bool/float etc. I want to know what "Cloud system" I should use in my situation, and how to synchronize my binary files to iCloud. Help would very much be appreciated!
Asked
by Henkepenk.
Last updated
.
Post not yet marked as solved
49 Views

On iOS 15.2, how do I load a cloudKit public container with user not logged in to iCloud

I am using the following to initialize my PersistenCloudKitContainer with the goal of loading a shared poblic cloudKit database: container = NSPersistentCloudKitContainer(name: "FaceExplorer")           guard let description = container.persistentStoreDescriptions.first else {        print("Can't set description")        fatalError("Error")      }             //ios 14 bug fix https://developer.apple.com/forums/thread/682925     description.cloudKitContainerOptions?.setValue(1, forKey: "databaseScope") // "normal" / ios 15 version description.cloudKitContainerOptions?.databaseScope = .public           //seems to work & Load on iOS14.5     description.cloudKitContainerOptions?.setValue("iCloud.com.myDomain.myContainerID", forKey: "containerIdentifier") container.loadPersistentStores(completionHandler: { (storeDescription, error) in ... This all works great on iOS14 and also loads on iOS15.0 - 15.2 with users logged into iCloud with the iCloud drive option checked. However, when the iCloud drive option is not checked on iOS15 only, the container will not load. Please help me figure out what I might be missing or doing wrong. Thanks
Asked
by orff.
Last updated
.
Post not yet marked as solved
414 Views

Can't open iCloud UIDocument when Files.App has SMB server connection and no network.

Normally iCloud documents can be opened when off-line. However, with ios 13, if you have an active SMB server connection in the Files App, and then the network is disabled, calls to UIDocument initWithFileURL: block indefinitely while attempting to lookup file attributes.Note calls to [UIDocument openWithCompletionHandler:], [NSURL getResourceValue:forKey:error:] and ExternalProviderPrepareValues.Backtrace:Thread 1 name: Dispatch queue: UIDocument File Access Thread 1: 0 libsystem_kernel.dylib 0x00000001b493a784 mach_msg_trap + 8 1 libsystem_kernel.dylib 0x00000001b4939ba8 mach_msg + 76 2 libdispatch.dylib 0x00000001b482bf10 _dispatch_mach_send_and_wait_for_reply + 552 3 libdispatch.dylib 0x00000001b482c304 dispatch_mach_send_with_result_and_wait_for_reply + 56 4 libxpc.dylib 0x00000001b476b96c xpc_connection_send_message_with_reply_sync + 240 5 Foundation 0x00000001b507a398 __NSXPCCONNECTION_IS_WAITING_FOR_A_SYNCHRONOUS_REPLY__ + 16 6 Foundation 0x00000001b4e40834 -[NSXPCConnection _sendInvocation:orArguments:count:methodSignature:selector:withProxy:] + 2668 7 Foundation 0x00000001b4e6faa8 -[NSXPCConnection _sendSelector:withProxy:arg1:arg2:arg3:] + 148 8 Foundation 0x00000001b50814a4 _NSXPCDistantObjectSimpleMessageSend3 + 48 9 FileProvider 0x00000001c93b6ba4 -[FPDaemonConnection valuesForAttributes:forItemAtURL:error:] + 428 10 FileProviderOverride 0x000000010e5b9f14 0x10e5b8000 + 7956 11 CoreFoundation 0x00000001b4b7cf14 __invoking___ + 148 12 CoreFoundation 0x00000001b4a46098 -[NSInvocation invoke] + 400 13 CoreFoundation 0x00000001b4a46cc0 -[NSInvocation invokeWithTarget:] + 80 14 FileProvider 0x00000001c9374db8 -[FPFrameworkOverridesIterator callNextOverrides] + 468 15 FileProvider 0x00000001c9374f58 -[FPFrameworkOverridesIterator forwardInvocation:] + 96 16 CoreFoundation 0x00000001b4b7a7d8 ___forwarding___ + 680 17 CoreFoundation 0x00000001b4b7cd60 _CF_forwarding_prep_0 + 96 18 FileProvider 0x00000001c9394cc0 FPCFCopyAttributeValuesForItem + 300 19 CoreServicesInternal 0x00000001b5ebba98 CopyFromFileProvider+ 154264 (__CFURL const*, void const*, void const**, __CFError**) + 88 20 CoreServicesInternal 0x00000001b5ebbe40 ExternalProviderPrepareValues+ 155200 (__CFURL const*, __FileCache*, __CFString const* const*, void const**, long, void const*, __CFError**) + 376 21 CoreServicesInternal 0x00000001b5ea8cc0 prepareValuesForBitmap+ 76992 (__CFURL const*, __FileCache*, _FilePropertyBitmap*, __CFError**) + 376 22 CoreServicesInternal 0x00000001b5ea69d4 _FSURLCopyResourcePropertyForKeyInternal+ 68052 (__CFURL const*, __CFString const*, void*, void*, __CFError**, unsigned char) + 220 23 CoreFoundation 0x00000001b4b40768 CFURLCopyResourcePropertyForKey + 140 24 CoreFoundation 0x00000001b4a4d190 -[NSURL getResourceValue:forKey:error:] + 120 25 Foundation 0x00000001b4ec43a0 +[NSFileVersion unresolvedConflictVersionsOfItemAtURL:] + 124 26 UIKitCore 0x00000001b86fcc90 -[UIDocument _setOpen:] + 144 27 UIKitCore 0x00000001b86fbb8c __40-[UIDocument openWithCompletionHandler:]_block_invoke + 676 28 libdispatch.dylib 0x00000001b4814ec4 _dispatch_call_block_and_release + 32 29 libdispatch.dylib 0x00000001b481633c _dispatch_client_callout + 20 30 libdispatch.dylib 0x00000001b481c85c _dispatch_lane_serial_drain + 568 31 libdispatch.dylib 0x00000001b481d290 _dispatch_lane_invoke + 400 32 libdispatch.dylib 0x00000001b4826928 _dispatch_workloop_worker_thread + 584 33 libsystem_pthread.dylib 0x00000001b487d714 _pthread_wqthread + 276 34 libsystem_pthread.dylib 0x00000001b48839c8 start_wqthread + 8Note the app doesn't use a Document Browser: UISupportsDocumentBrowser = FALSE. LSSupportsOpeningDocumentsInPlace = FALSE Using a single NSUbiquitousContainer with NSUbiquitousContainerIsDocumentScopePublic = FALSE
Asked
by michaelr.
Last updated
.
Post not yet marked as solved
1.2k Views

CloudKit record exists (added days ago), does not get returned by query but can be fetched by ID

I have a situation where a CloudKit record is not being returned by a query (and also doesn't appear in the CloudKit dashboard), but it exists when fetching it by it's ID.The record was added days ago, so it really should have been indexed.The record ID metadata index has always been set for the record type.The query I use is fetching all records for a particular record type in a custom zone.Strangely, when I search for the record in the dashboard and select it, the record name field is blank on the detail panel.It's very peculiar, and very concerning!Anyone have any ideas?
Asked
by Misbo.
Last updated
.
Post not yet marked as solved
126 Views

How to turn On/Off iCloudKitSync on a SwiftUI application

I'm trying to give the user the ability to decide whether they want to sync to CloudKit or not by turning On or Off a Switch located somewhere in the app settings screen but I'm not sure how to do it in SwiftUI. The following code successfully stops the sync to CloudKit by setting the cloud kit container options to nil description.cloudKitContainerOptions = nil. class CoreDataManager{ static let instance = CoreDataManager() let container: NSPersistentCloudKitContainer let context: NSManagedObjectContext init(){ container = NSPersistentCloudKitContainer(name: "CoreDataContainer") guard let description = container.persistentStoreDescriptions.first else{ fatalError("###\(#function): Failed to retrieve a persistent store description.") } description.setOption(true as NSNumber, forKey: NSPersistentHistoryTrackingKey) description.setOption(true as NSNumber, forKey: NSPersistentStoreRemoteChangeNotificationPostOptionKey) description.cloudKitContainerOptions = nil container.loadPersistentStores { (description, error) in if let error = error{ print("Error loading Core Data. \(error)") } } container.viewContext.automaticallyMergesChangesFromParent = true context = container.viewContext } func save(){ do{ try context.save() print("Saved successfully!") }catch let error{ print("Error saving Core Data. \(error.localizedDescription)") } } } What I ultimately want is to be able to control the syncing process with an @AppStore property or some sort of property, something like this... class CoreDataManager{ @AppStorage("iCloudSync") private var iCloudSync = false //missing code... init(){ if !iCloudSync{ description.cloudKitContainerOptions = nil } } //missing code... } But I'm facing a couple of issues, one, I'm getting an error when using the iCloudSync wrapper variable and the second one and the most difficult for me to solve is the fact that I need to make the persistent storage reload when the switch changes from On to Off of vise-versa. Any idea how can I structure my code so I can control the syncing process and be able to reload the persistent storage when the switch changes? By the way and just for reference, here is how I'm using the CoreDataManager class in my view model. class CarViewModel: ObservableObject{ let manager = CoreDataManager.instance @Published var cars: [Car] = [] init(){ getCars() } func addCar(){} func getCars(){} func deleteCar(){} func save(){ self.manager.save() } }
Asked
by fsdolphin.
Last updated
.
Post not yet marked as solved
224 Views

CoreData CloudKit Sync not working between iPad and iPhone

I have an application that uses CoreData as a persistent storage and recently implemented the support for iCloud-Sync. All works fine with my test devices (iPhones) and for most my users the synchronisation works as intended. However I have been getting a few emails lately, notifying me that the iCloud synchronisation does not seem to work for some users. All of those users are using iPhone devices and are trying to sync the data of the app to an iPad (or the other way around). It also only seems to be working one-sided. Data which is created on the users iPad syncs to their iPhones fine, however the iPhones data does not sync to their iPad. I think this is a weird issue and I haven't been able to resolve it yet. My app is designed for iPhone (iOS) only so far, so the iPad users are using the iPhone version on their iPad. What could cause this issue and how can it be resolved? Would be really grateful for some guidance!
Asked
by benedom.
Last updated
.
Post not yet marked as solved
204 Views

NSPinnedDomains in AppClip Info.plist doesn't seem to take for URLSession API

I submitted a feedback asking what would be safe prevent MITM attacks against CloudKit web APIs, pinning against the CA was an okay'd implementation. This is the response I got in my feedback: FB9445034 You can pin to the various Apple CA or sub-CA certificates that can be found here: https://www.apple.com/certificateauthority/public/ https://www.apple.com/certificateauthority/ All the certificates for CloudKit and iCloud web APIs have cert chains that point to the certificates listed. I have followed this article Identity Pinning and modified my App Clip info.plist accordingly to pin against CloudKit Web Services (https://api.apple-cloudkit.com). I intentionally mucked up the identity pin to verify my URLSession requests failed. I didn't receive any URLSession errors in my App Clip or Application targets when I had the plist updates in both. In reading these other forum posts I'm curious if the Identity Pinning is supported in App Clips or not. https://developer.apple.com/forums/thread/678081 https://developer.apple.com/forums/thread/681734
Asked
by edorphy.
Last updated
.