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

What is the aps-connection-initiate entitlement?
I use Core Data and CloudKit in my iOS app, and everything has worked flawlessly so far. I just got a new Mac with an M-chip and now have to run my app in a Rosetta Simulator. iOS17 Rosetta Simulator works great. But iOS16 Rosetta Simulator crashes as soon as I run any CloudKit code, console prints: [CK] BUG IN CLIENT OF CLOUDKIT: Not entitled to listen to push notifications. Please add the 'aps-connection-initiate' entitlement. Although I have "Push Notifications" capability enabled in "Signing and Capabilities" of the project. OK, I open the .entitlements file as a source code and add: <key>aps-connection-initiate</key> <true/> Can confirm, that it started working in the iOS16 Rosetta Simulator. But now I have an error in the Signing and Capabilities: Provisioning profile "iOS Team Provisioning Profile: com.###" doesn't include the aps-connection-initiate entitlement. What exactly is this aps-connection-initiate entitlement? And why haven't I needed it ever before? Should I upload it to App Store ASAP or remove it (since my current version works on iOS16 without this entitlement) Tried searching the web, couldn't find anything about this 'aps-connection-initiate' :'(
0
0
262
Aug ’24
Able to read from CloudKit shared database, but not write.
User A shares zone with User B (influenced from https://github.com/apple/sample-cloudkit-zonesharing, but I have just one zone "Contacts" that I am sharing): private func shareConfiguration() async throws -> (CKShare, CKContainer) { let container = CKContainer(identifier: "iCloud.com.***.syncer") let database = container.privateCloudDatabase let zone = CKRecordZone(zoneName: "Contacts") let fetchedZone = try await database.recordZone(for: zone.zoneID) guard let existingShare = fetchedZone.share else { print("Does not have existing share") let share = CKShare(recordZoneID: zone.zoneID) share[CKShare.SystemFieldKey.title] = "Resources" _ = try await database.modifyRecords(saving: [share], deleting: []) return (share, container) } print("Has existing share") guard let share = try await database.record(for: existingShare.recordID) as? CKShare else { throw NSError(domain: "", code: 0, userInfo: nil) } return (share, container) } ... let (share,container) = try! await shareConfiguration() shareView = CloudSharingView(container: container, share: share) // UIViewControllerRepresentable implementation User B accepts share invitation (borrowed from https://github.com/apple/sample-cloudkit-zonesharing) class SceneDelegate: UIResponder, UIWindowSceneDelegate { var window: UIWindow? func windowScene(_ windowScene: UIWindowScene, userDidAcceptCloudKitShareWith cloudKitShareMetadata: CKShare.Metadata) { guard cloudKitShareMetadata.containerIdentifier == "iCloud.com.***.syncer" else { print("Shared container identifier \(cloudKitShareMetadata.containerIdentifier) did not match known identifier.") return } // Create an operation to accept the share, running in the app's CKContainer. let container = CKContainer(identifier: "iCloud.com.***.syncer") let operation = CKAcceptSharesOperation(shareMetadatas: [cloudKitShareMetadata]) debugPrint("Accepting CloudKit Share with metadata: \(cloudKitShareMetadata)") operation.perShareResultBlock = { metadata, result in let shareRecordType = metadata.share.recordType switch result { case .failure(let error): debugPrint("Error accepting share: \(error)") case .success: debugPrint("Accepted CloudKit share with type: \(shareRecordType)") } } operation.acceptSharesResultBlock = { result in if case .failure(let error) = result { debugPrint("Error accepting CloudKit Share: \(error)") } } operation.qualityOfService = .utility container.add(operation) } } User B through CKSyncEngine is able to read all records. However, when User B tries to write to database through CKSyncEngine, User B on his device gets following error: <CKSyncEngine 0x1282a1400> error fetching changes with context <FetchChangesContext reason=scheduled options=<FetchChangesOptions scope=all group=CKSyncEngine-FetchChanges-Automatic)>>: Error Domain=CKErrorDomain Code=2 "Failed to fetch record zone changes" UserInfo={NSLocalizedDescription=Failed to fetch record zone changes, CKPartialErrors={ "<CKRecordZoneID: 0x3024872a0; zoneName=Contacts, ownerName=_18fb98f978ce4e9c207daaa142be6024>" = "<CKError 0x30249ed60: \"Zone Not Found\" (26/2036); server message = \"Zone does not exist\"; op = DC9089522F9968CE; uuid = 4B3432A4-D28C-457A-90C5-129B24D258C0; container ID = \"iCloud.com.***.syncer\">"; }} Also, in CloudKit console, if I go to Zones, I don't see any zones under Shared Database. Wasn't I supposed to see my zone here? However, I see "Contacts" zone under Private Database. If I expand Zone details I see following: Zone wide sharing is enabled. All records in this zone are being shared with the sharing participants below. And under Participants I see both User A and User B. User B is marked as: Permission READ_WRITE Type USER Acceptance INVITED What puzzles me is why READ works, but not WRITE?
1
1
323
Aug ’24
Swift Data and CloudKit
I have SwiftData configured with CloudKit iCloud sync, and the sync is initiated only when the application is launched or the scene phase is changed. CloudKit remote notifications are not received while the application is running; instead, each sync remote notification is sent to app only upon a scene phase change, such as transitioning from the Home Screen to the Main Screen and returning. Subsequently, the application syncs with the most recent data. I have observed other individuals who have implemented a similar sync but with diffrent data, where a record is added on one device, and it appears on the other device without the need to change the scene phase. Currently, I am using two physical devices: a Mac and an iPhone. The Mac is running macOS 15.1 beta 2, while the iPhone is running iOS 18.0 beta 6 Xcode Version is 15.1. CloudKit Sync Issue: CloudKit remote notifications to update data only appear when the app’s scene phase changes, not when the app is running. Sync Trigger: To sync again, the scene phase needs to be changed to trigger the sync. App uses @Query macro with different predicates like @Query(filter: #Predicate<Payment>{ $0.isPinned && $0.renewalID != 1000 }, sort: \.pinnedOrder, animation: .smooth) private var paymentsData: [Payment] @Query var data: [Payment] and the predicate is made in the initializer of the view. init(searchText: String) { self.searchText = searchText let billsPredicate = #Predicate<Payment>{$0.renewalID != 1000 } _bills = Query(filter: billsPredicate, animation: .smooth) let pinnedPredicate = #Predicate<Payment>{ if searchText.isEmpty{ $0.isPinned && $0.renewalID != 1000 }else{ $0.isPinned && $0.renewalID != 1000 && $0.name.localizedStandardContains(searchText) } } _pinnedBills = Query(filter: pinnedPredicate, sort: \.pinnedOrder, animation: .smooth) let notPinnedPredicate = #Predicate<Payment>{ if searchText.isEmpty{ !$0.isPinned && $0.renewalID != 1000 }else{ !$0.isPinned && $0.renewalID != 1000 && $0.name.localizedStandardContains(searchText) } } _notPinnedBills = Query(filter: notPinnedPredicate, sort: \.name, animation: .smooth) } *The application has minimal deployment targets set to iOS 17.0, macOS Sonoma 14.0, watchOS 10.0, and visions 1.1. When I tested it I used two builds just compiled in Xcode or two builds downloaded from TestFlight All CloudKit Container changes are deployed to production and app bundle id is like app.SomeApp and container id is iCloud.app.SomeApp *I verified the functionality by adding a record on one device and observing it appearance on another device. Alternatively, I modified record details, such as the name, in the CloudKit Console and watch for changes without app restart. Every time scene phase is needed to trigger sync and see changes. What actions can I take to ensure data synchronization or download occurs when the application is in use? (scenePhase is .active )
1
0
469
Aug ’24
Can't accept CloudKit share invitation from my SwiftUI application
I am able to send invitation from my device to friend's device. When friend clicks on invitation that was shared through text messages it says: Open "Resources"? User X wants to collaborate. You'll join as User Y (user Y @iCloud.com). |Not Now| |Open| If friend clicks on |Open| then nothing happens. Share remains in "invited" state and the callbacks which I expected to be called are not. The official Apple CloudKit Sharing App - https://github.com/apple/sample-cloudkit-sharing/blob/main/Sharing/App/AppDelegate.swift - is confusing me because it does not have following code like typical SwiftUI app: @main struct MainApp: App { Instead it uses @main for AppDelegate. Here is my code with prints that encode what is going on: class AppDelegate: UIResponder, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { print("I see this getting called on App startup") return true } func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { print("I also see this getting called on App startup") return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) } func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) { print("I don't see this getting called") } func application(userDidAcceptCloudKitShareWith cloudKitShareMetadata: CKShare.Metadata) -> Bool { print("However, I expected this to be called when friend opened his CloudKit share invitation") return false } } @main struct MainApp: App { @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate static let sharedModelActor: ModelActorDatabase = { let schema = Schema([ Resource.self, ]) let modelConfiguration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: false, cloudKitDatabase: .none) do { let modelContainer = try ModelContainer(for: schema, configurations: [modelConfiguration]) return ModelActorDatabase(modelContainer: modelContainer) } catch { fatalError("Could not create ModelContainer: \(error)") } }() @StateObject var syncedDatabase: SyncedDatabase = SyncedDatabase(modelContainer: Self.sharedModelActor.modelContainer) var body: some Scene { WindowGroup { ResourceView() .environmentObject(syncedDatabase) } .modelContainer( Self.sharedModelActor.modelContainer ) .database(SharedDatabase.shared.database) } } I was expecting that this would call userDidAcceptCloudKitShareWith, but it is not. Why?
1
0
319
Aug ’24
There are some difference between Push Notifications Platform 's statue result and doc
in Push Notifications Platform : when i test the device remove our app , the status result is “- discarded as device was offline” when i test close the notification auth in our app, the status result is “- stored for device power considerations" but i saw the flow in doc , I didn't directly saw that these two states are like this https://developer.apple.com/documentation/usernotifications/viewing-the-status-of-push-notifications-using-metrics-and-apns how can i know the directly status in this two cases ?
0
0
317
Aug ’24
How to retrieve previously set title for a CKShare?
I create a CKShare and then I set the title: share[CKShare.SystemFieldKey.title] = title I even call: if let cloudStore = coreDatabase.cloudStore { try await persistentContainer.persistUpdatedShare(share, in: cloudStore) } but when I retrieve this share again using persistentContainer.fetchShares(matching: [id]) the title is not set. I even checked CloudKit console and I can't see there title either... How can I retrieve the previously set title for a share?
1
0
325
Aug ’24
How to properly share one CKREcord with CKShare in obj-c
When I trying to set share record I get: NSOperationQueue * quwuw = [[NSOperationQueue alloc] init]; [quwuw setMaxConcurrentOperationCount:1]; [self createOrFetchZone:^(CKRecordZone *rzone, NSError *error) { CKRecordID *recordID = [[CKRecordID alloc] initWithRecordName:recordId zoneID:custZone.zoneID]; [[self privateCloudDatabase] fetchRecordWithID:recordID completionHandler:^(CKRecord *record, NSError *error) { if (error) { dispatch_async(dispatch_get_main_queue(), ^{ prephandler(nil, nil,error); }); return; } CKShare * share = [[CKShare alloc] initWithRootRecord:record]; share[CKShareTitleKey] = @"Some title"; [share setPublicPermission:CKShareParticipantPermissionReadWrite]; CKModifyRecordsOperation * op = [[CKModifyRecordsOperation alloc] initWithRecordsToSave:@[share, record] recordIDsToDelete:nil]; [op setModifyRecordsCompletionBlock:^(NSArray<CKRecord *> * _Nullable savedRecords, NSArray<CKRecordID *> * _Nullable deletedRecordIDs, NSError * _Nullable operationError) { if (operationError == nil) { dispatch_async(dispatch_get_main_queue(), ^{ prephandler(share, [CKContainer defaultContainer],operationError); }); } else { dispatch_async(dispatch_get_main_queue(), ^{ prephandler(share, [CKContainer defaultContainer],operationError); }); } }]; [op setDatabase:[self privateCloudDatabase]]; [quwuw addOperation:op]; }]; }]; I get error: Invalid Arguments" (12/2006); server message = "Chaining supported for hierarchical sharing only" Any advices for this?
0
0
261
Aug ’24
How to remove a single record from a CKShare?
It is possible to append a record to a CKShare using NSPersistentCloudKitContainer.share(objects, to: share) but how can I reverse this operation and remove the object from share? The workaround would be to delete and recreate the object, but is there any SDK function to do it right? The more I work with CoreData+CloudKit the more it seems like everything there is a workaround or hack or bug... This SDK is still in Alpha at best.
0
0
275
Aug ’24
CKModifyBadgeOperation is no longer working?
Whilst all current answers to this question indicate the depreciation of CKModifyBadgeOperation, all of them had advised up until 2022 that it could still be used due to Apple not having a replacement Api. Upon running the following code: badgeReset.modifyBadgeCompletionBlock = { (error) -> Void in if error != nil { print("Error resetting badge: \(error!)") } } CKContainer.default().add(badgeReset) When run I receive the following error: Error resetting badge: <CKError 0x3001ddf50: "Invalid Arguments" (12/1017); "CKModifyBadgeOperation is no longer supported"> And from testing following this, the badge count incrementation issue continues, indicating that this has been completely invalidated and cannot be used at all. Even with UNUserNotificationCenter.current().setBadgeCount(0) this only clears the badge count temporarily. I'm aware of the proposed "workaround" of creating an extension that manually keeps track of notification count & sets the badge accordingly when a notification is received. However I'm trying to ascertain if as of this current point in time there is now no way whatsoever to clear the badge count on the Cloudkit sever level?
3
0
455
Sep ’24
"Internal Error" in CloudKit Dashboard
Hi, I'm getting an "Internal Error" in the CloudKit Dashboard for my user. This happens for the Private database across all of my apps, and in both Development and Production environments. (Screenshot attached). If I login as a different user via the 'Act as iCloud Account' function, everything works fine - it seems to be an issue with my own user account. In the JavaScript console, I see "Known response error: The request has failed due to an error.", but no other details (Screenshot attached) I can see these failures in the Logs tag, showing as 'INTERNAL_ERROR' (another Screenshot) It appears that the data on my account is currently not sync'ing to CloudKit, although I haven't found any other errors from within the app claiming that there is an issue (using the CoreData+CloudKit integration). I'm assuming my in-app errors and my dashboard errors are related, although it's difficult to say without more information on what these errors actually are.
4
0
450
Aug ’24
SwiftData 0xdead10cc with cloudKitDatabase
I recently added SwiftData to my project in a limited capacity. I'm creating ModelConfiguration -> ModelContext directly in Swift code rather than in SwiftUI. I'm using an app group & a CloudKit database/container. The functionality all seems fine, but I'm dealing with random 0xdead10cc crashes from threads with CoreData/libsqlite3.dylib in the stack traces (particularly with widgets & complications which aren't actively writing anything), often with NSCloudKitMirroringDelegate.m also in the stack. I haven't seen any actual functionality issues, but the crashing is worrisome. I understand they're keeping files open to cause the 0xdead10cc, but my question is: Is there a clean way to shut down or force shut down SwiftData when using CloudKit? I've looked through example code on Apple's Developer site, but I can't seem to find anything about cleanup/shutdown best practices, though I may be missing something. Here's an example thread from a crash log: Thread 12: 0 libsystem_kernel.dylib 0x00000000258b4fe4 pread + 12 1 libsqlite3.dylib 0x0000000023ce7684 seekAndRead + 88 (sqlite3.c:44032) 2 libsqlite3.dylib 0x0000000023c5ffc4 unixRead + 200 (sqlite3.c:44124) 3 libsqlite3.dylib 0x0000000023c730fc readDbPage + 132 (sqlite3.c:66901) 4 libsqlite3.dylib 0x0000000023cf14e4 getPageNormal + 532 (sqlite3.c:69515) 5 libsqlite3.dylib 0x0000000023cfd684 getAndInitPage + 104 (sqlite3.c:79184) 6 libsqlite3.dylib 0x0000000023c8f99c moveToRoot + 532 (sqlite3.c:82309) 7 libsqlite3.dylib 0x0000000023cfa448 sqlite3BtreeTableMoveto + 168 (sqlite3.c:82547) 8 libsqlite3.dylib 0x0000000023c859fc sqlite3VdbeExec + 4996 (sqlite3.c:105391) 9 libsqlite3.dylib 0x0000000023c83da4 sqlite3_step + 976 (sqlite3.c:97868) 10 CoreData 0x00000000211c92d4 _execute + 128 (NSSQLiteConnection.m:4573) 11 CoreData 0x00000000211c5e74 -[NSSQLiteConnection execute] + 1784 (NSSQLiteConnection.m:5014) 12 CoreData 0x000000002121c3f8 -[NSSQLiteConnection insertRow:] + 1488 (NSSQLiteConnection.m:3608) 13 CoreData 0x00000000211ca160 _executeSaveChangesRequest + 1792 (NSSQLCore_Functions.m:2543) 14 CoreData 0x00000000211dc128 -[NSSQLSaveChangesRequestContext executeRequestCore:] + 28 (NSSQLSaveChangesRequestContext.m:263) 15 CoreData 0x00000000211fa424 -[NSSQLStoreRequestContext executeRequestUsingConnection:] + 220 (NSSQLStoreRequestContext.m:183) 16 CoreData 0x00000000211cce3c __52-[NSSQLDefaultConnectionManager handleStoreRequest:]_block_invoke + 56 (NSSQLConnectionManager.m:302) 17 CoreData 0x00000000211c99d4 __37-[NSSQLiteConnection performAndWait:]_block_invoke + 40 (NSSQLiteConnection.m:733) 18 libdispatch.dylib 0x0000000020af2b94 _dispatch_client_callout + 16 (object.m:576) 19 libdispatch.dylib 0x0000000020b004d8 _dispatch_lane_barrier_sync_invoke_and_complete + 56 (queue.c:1104) 20 CoreData 0x00000000211c3d4c -[NSSQLiteConnection performAndWait:] + 140 (NSSQLiteConnection.m:730) 21 CoreData 0x000000002122fb3c -[NSSQLDefaultConnectionManager handleStoreRequest:] + 208 (NSSQLConnectionManager.m:297) 22 CoreData 0x00000000211bd16c -[NSSQLCoreDispatchManager routeStoreRequest:] + 216 (NSSQLCoreDispatchManager.m:60) 23 CoreData 0x00000000211bfb8c -[NSSQLCore dispatchRequest:withRetries:] + 168 (NSSQLCore.m:3999) 24 CoreData 0x00000000211c0480 -[NSSQLCore executeRequest:withContext:error:] + 2044 (NSSQLCore.m:2963) 25 CoreData 0x000000002134662c __65-[NSPersistentStoreCoordinator executeRequest:withContext:error:]_block_invoke.387 + 8968 (NSPersistentStoreCoordinator.m:2967) 26 CoreData 0x00000000211c6190 -[NSPersistentStoreCoordinator _routeHeavyweightBlock:] + 220 (NSPersistentStoreCoordinator.m:644) 27 CoreData 0x00000000211bf3fc -[NSPersistentStoreCoordinator executeRequest:withContext:error:] + 1112 (NSPersistentStoreCoordinator.m:2779) 28 CoreData 0x00000000211d5468 -[NSManagedObjectContext save:] + 988 (NSManagedObjectContext.m:1624) 29 CoreData 0x0000000021296ba8 __52+[NSCKEvent beginEventForRequest:withMonitor:error:]_block_invoke_2 + 280 (NSCKEvent.m:76) 30 CoreData 0x00000000211d1024 developerSubmittedBlockToNSManagedObjectContextPerform + 156 (NSManagedObjectContext.m:3987) 31 libdispatch.dylib 0x0000000020af2b94 _dispatch_client_callout + 16 (object.m:576) 32 libdispatch.dylib 0x0000000020b004d8 _dispatch_lane_barrier_sync_invoke_and_complete + 56 (queue.c:1104) 33 CoreData 0x00000000211e3d8c -[NSManagedObjectContext performBlockAndWait:] + 256 (NSManagedObjectContext.m:4104) 34 CoreData 0x000000002129e14c __52+[NSCKEvent beginEventForRequest:withMonitor:error:]_block_invoke + 152 (NSCKEvent.m:66) 35 CoreData 0x00000000212231d0 -[PFCloudKitStoreMonitor performBlock:] + 84 (PFCloudKitStoreMonitor.m:148) 36 CoreData 0x0000000021284c28 +[NSCKEvent beginEventForRequest:withMonitor:error:] + 184 (NSCKEvent.m:61) 37 CoreData 0x000000002125fb80 __57-[NSCloudKitMirroringDelegate _performExportWithRequest:]_block_invoke + 256 (NSCloudKitMirroringDelegate.m:1435) 38 CoreData 0x0000000021209cb4 __92-[NSCloudKitMirroringDelegate _openTransactionWithLabel:assertionLabel:andExecuteWorkBlock:]_block_invoke + 64 (NSCloudKitMirroringDelegate.m:959) 39 libdispatch.dylib 0x0000000020af1288 _dispatch_call_block_and_release + 24 (init.c:1549) 40 libdispatch.dylib 0x0000000020af2b94 _dispatch_client_callout + 16 (object.m:576) 41 libdispatch.dylib 0x0000000020af96bc _dispatch_lane_serial_drain + 680 (queue.c:3934) 42 libdispatch.dylib 0x0000000020afa124 _dispatch_lane_invoke + 376 (queue.c:4025) 43 libdispatch.dylib 0x0000000020b03c40 _dispatch_root_queue_drain_deferred_wlh + 268 (queue.c:7193) 44 libdispatch.dylib 0x0000000020b034fc _dispatch_workloop_worker_thread + 516 (queue.c:6787) 45 libsystem_pthread.dylib 0x0000000025f9b7bc _pthread_wqthread + 280 (pthread.c:2696) 46 libsystem_pthread.dylib 0x0000000025f9b85c start_wqthread + 8 (:-1)
1
0
306
Aug ’24
Swiftdata using an existing CloudKit container, how to listen to the NSPersistentCloudKitContainer's NSPersistentStoreRemoteChange event
My app uses SwiftData and CloudKit to store and synchronize data. This works nice. in some scenarios, I need to listen to NSPersistentStoreRemoteChange event to deduplicate data. In SwiftData, how do I get the persistentStoreCoordinator of the corresponding SwiftData ModelContainer? Or are there other APIs to achieve the same purpose? There is no relevant content in the developer documentation. In addition, in wwdc 24, there is a new API to track history (https://developer.apple.com/cn/videos/play/wwdc2024/10075/). But there is no mention of how to listen to remote data change events either.
1
0
461
Aug ’24
Managing Duplicate Objects in Core Data (or SwiftData) with CloudKit Sync When Devices were Offline during object creation
Suppose I have two iPhones that are offline. On the first iPhone, at 1 PM, I create a Person object with the details: name: "John", lastName: "Smith", and age: 40. Then, on the second iPhone, which is also offline, I also create Person object at 2 PM with the same name: "John" and lastName: "Smith", but with a different age: 30. Both iPhones come online at 3 PM and sync with CloudKit. I would expect CloudKit to reconcile these two records and end up with a single record—specifically, Person(name: "John", lastName: "Smith", age: 30), assuming a "last writer wins" approach. Any guidance or best practices for handling this situation would be greatly appreciated! My idea is that I could generate a 128bit UUID as hash from first name and last name and then I would have to force this UUID to be used as recordName in CKRecord as this would trigger a conflict on CloudKit side and prevent two instance to be created. But how do I accomplish this with SwiftData or CoreData?
3
0
710
Aug ’24
SwiftData and CloudKit
Recently I've been working on a demo project called iLibrary. The main goal was to learn more about CloudKit and SwiftData. After a while I noticed that there were some hangs/freezes when running the app in debug mode. I first tried this with Xcode 15.4 and iOS 17.5. Here the hang only appears at the beginning, but only for a few seconds. But when I exit debug mode, there are no more hangs. With Xcode 16 beta 4 and iOS 18 it looks completely different. In this case, the hangs and freezes are always present, whether in debug mode or not. And it's not just at the beginning, it's throughout the app. I'm aware that this is still a beta, but I still find this weird. And when I profile this I see that the main thread gets quite overloaded. Interestingly, my app doesn't have that many operations going on. So I guess something with the sync of SwiftData or my CloudKitManger where I fetch some records from the public database is not running fine. Lastly, I wanted to delete the iCloud app data. So I went to Settings and tried to delete it, but it didn't work. Is this normal? Does anyone have any idea what this could be? Or has anyone encountered this problem as well? I'd appreciate any support. My project: https://github.com/romanindermuehle/iLibrary
5
3
587
Oct ’24
CoreData sharing/collaboration feature is broken
On top of unstable CloudKit sync, we've got also extremely unstable sharing/collaboration functionality. I mean, it's quite impressive how easy it is to enable sharing, but this feature should not be released at this point. It feels like using software in the alpha version. Let's take NSPersistentCloudKitContainer.share(_:to:) (https://developer.apple.com/documentation/coredata/nspersistentcloudkitcontainer/3746834-share), the documentation says: Sharing fails if any of the following conditions apply: Any objects in managedObjects, or those the traversal finds, belong to > an existing share record. However, it's wrong... if you pass any object from the existing share, it will return the same share... It never fails in this case. Things are getting even weirder if you experiment a little bit with shares. So let's assume you share a couple of objects: persistentContainer.share([A, B, C, D], to: nil) Now you stop sharing those via UICloudSharingController and you want to share again but just C. So you call: persistentContainer.share([C], to: nil) and surprise, surprise, you get a new share URL, but you share all previously shared objects (A, B, C, D), not as you would have expected only C... On top of that, you keep getting some weird errors like: error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _requestAbortedNotInitialized:](2190): <NSCloudKitMirroringDelegate: 0x3029b84b0> - Never successfully initialized and cannot execute request '<NSCloudKitMirroringExportRequest: 0x30359f1b0>123123123123' due to error: <CKError 0x3018699b0: "Partial Failure" (2/1011); "Failed to modify some record zones"; uuid = 12312312312312; container ID = "iCloud.some.id"; partial errors: { com.apple.coredata.cloudkit.share.123123123123123:__defaultOwner__ = <CKError 0x30186a3d0: "Invalid Arguments" (12/2006); server message = "Only shared zones can be accessed in the shared DB"; op = 12312312312312; uuid = 123123123123> }> Even though the only thing I use is persistentContainer.share and UICloudSharingController(share: share, container: cloudKitContainer) And the cherry on the top, from time to time if you play a little with sharing multiple objects at once, it happens that it randomly wipes out some records from that share... I don't even know where to start reporting issues and if its worth it, because every ticket will be dismissed anyway because "we need thousands of your logs, we require you to do all the job for us".
1
0
386
Aug ’24
Question about saving Data with SwiftData and CloudKit
My app is using SwiftData with CloudKit integration. Everything at the moment is working fine. I have a struct that saves Data as an optional. This is Data related to an Image. It saves and loads as expected. When I disconnect my phone from wifi or my phone network, the image still loads. I'm assuming that means the Data is being stored locally on the phone as well. Is there a way to display what's stored locally to the user inside the application? Edit: I've realized that CloudKit is saying the data is too large, but the images are still being saved. Does that mean they're only locally being saved?
1
0
277
Aug ’24