CoreData+CloudKit integration issue

Hello. I'm trying to setup CoreData+CloudKit integration. But I receive following errors right after NSPersistentCloudKitContainer configuration.

 CoreData: error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _performSetupRequest:]_block_invoke(939): <NSCloudKitMirroringDelegate: 0x282d18a90>: Failed to set up CloudKit integration for store: <NSSQLCore: 0x10342fbf0> (URL: file:///var/mobile/Containers/Data/Application/18992BCF-7F0C-4271-B106-947B8F52A723/Library/Application%20Support/App.sqlite)
Error Domain=NSCocoaErrorDomain Code=134060 "A Core Data error occurred." UserInfo={NSLocalizedFailureReason=The mirroring delegate could not initialize because it's store was removed from the coordinator.}

Here is the code of persistent container setup:

self.persistentContainer = NSPersistentCloudKitContainer(name: containerName)
 
let localStorage = NSPersistentStoreDescription(url: storageURL)
let localStorageOptions = NSPersistentCloudKitContainerOptions(containerIdentifier: "iCloud.com.myapp")
localStorageOptions.databaseScope = .private
localStorage.cloudKitContainerOptions = localStorageOptions
persistentContainer.persistentStoreDescriptions = [localStorage]
   
persistentContainer.loadPersistentStores { storeDescription, error in
  if let error = error {
    print(error)
  }
}

Another thing to mentioned is that storageURL is a shared app group folder.

Not sure what exactly went wrong here, so would be happy to get any help!

CoreData+CloudKit integration issue
 
 
Q