Resume long lived operation failed with error CKDatabaseOperations must be submitted to a CKDatabase

After upgrading to iOS 15 beta 4, several users report the app crashes shortly when launch.

Debug in the device, we had the same crash:

*** Terminating app due to uncaught exception 'CKException', reason: 'CKDataBaseOperations must be submitted to a CKDatabase'

The user info in this CKError leads us to this line:

// Called when app launches

final class PrivateDatabaseManager {
    
    let container: CKContainer
    let database: CKDatabase
    
    public init(container: CKContainer) {
        self.container = container
        self.database = container.privateCloudDatabase
    }
    
    func resumeLongLivedOperationIfPossible() {
        container.fetchAllLongLivedOperationIDs { [weak self]( opeIDs, error) in
            guard let self = self, error == nil, let ids = opeIDs else { return }
            for id in ids {
                self.container.fetchLongLivedOperation(withID: id, completionHandler: { [weak self](ope, error) in
                    guard let self = self, error == nil else { return }
                    if let modifyOp = ope as? CKModifyRecordsOperation {
                        modifyOp.modifyRecordsCompletionBlock = { (_,_,_) in
                            print("Resume modify records success!")
                        }
                        self.container.add(modifyOp)
                    }
                })
            }
        }
    }
}

If we add a break point in this line, the properties in modifyOp look fine. and we don't have this issue before this beta.

Checking the crash data we collect in firebase, the operating system is 100% iOS 15.

Using:

Xcode: Version 13.0 beta 3 (13A5192j)

Device: 15.0 (19A5307g)

I am observing the same issue since iOS 15 beta 4 as well.

Same here, iPadOS 15 beta Terminating app due to uncaught exception 'CKException', reason: 'Terminating app due to uncaught exception 'CKException', reason: 'CKDatabaseOperations must be submitted to a CKDatabase'

I am observing this same issue. It only happens if the app is built with the iOS 15 SDK.

iOS 15 beta 5 fixes this issue =)

I faced the same problem, but I have beta 6. Any ideas?

i tried replacing self.container.add (modifyOp) with self.database.add (modifyOp) and it seems to work, but i'm not sure if the solution is correct

Same here beta 6

Unable to find the edit button, I'll attach more logs here.

Debug with: Xcode 13.0 beta 5 (13A5212g) iOS 15 beta 7

2021-08-27 16:23:51.202825+0800 MyApp[431:12260] [xpc.exceptions] <NSXPCConnection: 0x282a6f2a0> connection to service with pid 129 named com.apple.cloudd: Exception caught during invocation of reply block to message 'fetchLongLivedOperationsWithIDs:completionHandler:'.



Exception: CKDatabaseOperations must be submitted to a CKDatabase

(

	0   CoreFoundation                      0x00000001820db070 556693B0-3E65-30B3-B026-7107FD29DC41 + 626800

	1   libobjc.A.dylib                     0x000000019a58df64 objc_exception_throw + 60

	2   CloudKit                            0x000000018948c1b4 CKStringFromApplicationPermissionStatus + 6784

	3   CloudKit                            0x0000000189495e6c CKStringFromApplicationPermissionStatus + 46904

	4   OffScreenKit                        0x00000001070753d0 $s8IceCream15DatabaseManagerPAAE34resumeLongLivedOperationIfPossibleyyFySaySSGSg_s5Error_pSgtcfU_ySo11CKOperationCSg_AHtcfU_ + 536

	5   libswiftCloudKit.dylib              0x000000019fe60760 0F47946A-53BB-344F-ABC5-228D48BAE29F + 100192

	6   CloudKit                            0x0000000189494098 CKStringFromApplicationPermissionStatus + 39268

	7   CloudKit                            0x00000001894939d4 CKStringFromApplicationPermissionStatus + 37536

	8   CoreFoundation                      0x0000000182064304 556693B0-3E65-30B3-B026-7107FD29DC41 + 140036

	9   CoreFoundation                      0x0000000182081ad4 556693B0-3E65-30B3-B026-7107FD29DC41 + 260820

	10  Foundation                          0x00000001838a1930 AD55BAA6-3C1C-3392-AFBC-73E9063C34B9 + 219440

	11  Foundation                          0x00000001838c2828 AD55BAA6-3C1C-3392-AFBC-73E9063C34B9 + 354344

	12  Foundation                          0x000000018389d4b4 AD55BAA6-3C1C-3392-AFBC-73E9063C34B9 + 201908

	13  libxpc.dylib                        0x00000001f216732c A519A4A5-9D87-3B62-9585-41EDADDD5127 + 115500

	14  libxpc.dylib                        0x00000001f215a85c A519A4A5-9D87-3B62-9585-41EDADDD5127 + 63580

	15  libdispatch.dylib                   0x0000000181d4d9d0 70FBC63E-C446-3BD3-A3BD-6F022317469B + 14800

	16  libdispatch.dylib                   0x0000000181d6afd4 70FBC63E-C446-3BD3-A3BD-6F022317469B + 135124

	17  libdispatch.dylib                   0x0000000181d54f84 70FBC63E-C446-3BD3-A3BD-6F022317469B + 44932

	18  libdispatch.dylib                   0x0000000181d55c44 70FBC63E-C446-3BD3-A3BD-6F022317469B + 48196

	19  libdispatch.dylib                   0x0000000181d60318 70FBC63E-C446-3BD3-A3BD-6F022317469B + 90904

	20  libsystem_pthread.dylib             0x00000001f21311b0 _pthread_wqthread + 288

	21  libsystem_pthread.dylib             0x00000001f2130f50 start_wqthread + 8

)
Resume long lived operation failed with error CKDatabaseOperations must be submitted to a CKDatabase
 
 
Q