databaseScope lead to dyld: Library not loaded on xcode13-beta with simulator 14.5

Hey!

recently I did some changes to my apps to fit iOS 15 and noticed that the import of CloudKit is now require for some iCloud CoreData functions like description.cloudKitContainerOptions?.databaseScope = .private or CKFetchRecordZonesOperation.fetchAllRecordZonesOperation(). This works fine until I change the Simulator to iOS 14.5, which leading to the follow crash:

dyld: Library not loaded: /System/Library/Frameworks/_CoreData_CloudKit.framework/_CoreData_CloudKit

  Referenced from: /private/var/containers/Bundle/Application/DBD9242D-A85E-4957-948A-D770C6C6D6B5/CoreDataTest.app/CoreDataTest

  Reason: image not found

It's also replicable on real devices. I also set CloudKit.framework under the Generals-Tab and set it to optional in Build Phase. Still not working. What do I missing?

You cannot mix applications built against the iOS 15 SDK with iOS 14.* devices or simulators.

Hi did you ever find a fix for this? I'm having the same issue. I am using Xcode 13 beta 5, deployment target is set to 14.0.

Has anyone found a solution here? or the root cause of the problem?

This thread was initially commented by a "Frameworks Engineer" and then left unanswered with multiple people having the same problem.

Not an answer I’m afraid, but perhaps a related problem. They’ve definitely changed something deep at the OS level which is even affecting the CloudKit syncing of apps built with the iOS 14 SDK many months ago (ie. my app!) if run on an iOS 15 device, let alone apps built with the iOS 15 SDK!

This failure of syncing started to occur when iOS 15 beta 4 was released - prior to this it was all working normally, as it did in iOS 13 & iOS 14. From beta 4 the entire structure of the console log outputs for NSPersistentCloudKitContainer changed, so something fundamental changed with CloudKit at this time.

In my case, it seems it has trouble syncing Core Data relationships and NSPersistentCloudKitMirrorringDelegate gets stuck in a loop causing CPU & RAM consumption to rise uncontrollably, with the OS killing the app shortly afterwards. No syncing occurs. My Core Data structure has not changed since iOS 14 and my app synced (and still does) just fine on iOS 14 devices.

Other than a reply from a ‘Frameworks Engineer’ briefly, I’ve had no communication from Apple, nor an acknowledgement that this is even an issue, including in my Feedback report - nobody from Apple has replied there. It’s extremely disheartening particularly as they’ve released the Release Candidate and it’s still broken. I’m going to have many very upset users (medical professionals) in a few days.

If it didn’t affect Apps built 6 months ago with the iOS 14 SDK I wouldn’t really be that concerned as I could just hold off my iOS 15 release until this is fixed, but it’s breaking existing apps which is totally unacceptable.

Here’s my thread on it: https://developer.apple.com/forums/thread/687877

I’ve submitted a Technical Support Incident (at my expense) now that iOS 15 is ‘final’ in the hope that someone will acknowledge this!

I’ve not found a solution either. Since I switched to the Xcode 13 RC, all of my beta testers are now crashing! This is holding up a release.

At the moment, you'll need to remove this line:

description.cloudKitContainerOptions?.databaseScope = .private

since .private is the default, it isn't doing anything. If you need to use .public, you'll have to set it from an ObjC thunk. If you file a feedback assistant issue, ADC will contact you directly when it's fixed, or get you some assistance to work around it.

To use the private database scope, you can work around this issue by deleting the code to set the databaseScope property on the NSPersistentCloudKitContainerOptions object since it is the default value.

To use the public database scope, you can work around this issue with KeyValueCoding:

let options = NSPersistentCloudKitContainerOptions(containerIdentifier: id) options.setValue(1, forKey: "databaseScope") // .public == 1 // options.databaseScope = CKDatabase.Scope.public description.cloudKitContainerOptions = options

databaseScope lead to dyld: Library not loaded on xcode13-beta with simulator 14.5
 
 
Q