I am trying to build a very basic app using Core Data and CloudKit. I am logged into my CloudKit account on my Mac, and I followed the instructions to run the sample project that Apple provided on their website.Using the sample project as a guide, I tried to build a simpler app using the instructions provided here.However, after building trying to run my sample project, I get the following error stack trace in my console:CoreData: debug: CoreData+CloudKit: -[PFCloudKitOptionsValidator validateOptions:andStoreOptions:error:](35): Validating options: <NSCloudKitMirroringDelegateOptions: 0x60000097f960> containerIdentifier:iCloud.com.cybermedia.CloudKitTest1 initializeSchema:YES ckAssetThresholdBytes:<null> operationMemoryThresholdBytes:<null> useEncryptedStorage:NO automaticallyDownloadFileBackedFutures:NO automaticallyScheduleImportAndExportOperations:YES skipCloudKitSetup:NO preserveLegacyRecordMetadataBehavior:NO useDaemon:YES apsConnectionMachServiceName:<null> containerProvider:<
Search results for
NSPersistentCloudKitContainer
589 results found
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I have consulted the documentation here: https://developer.apple.com/documentation/coredata/nspersistentcloudkitcontainer/event?changes=latest_minor however there is no information that describes how this event works, can I expect documentation in the future?
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags:
If you Changed the name of your .xcdatamodel file ensure that the same name you changed it to is used when making your container in AppDelegate.swift as below let container = NSPersistentCloudKitContainer(name: Same Name )
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags:
I spoke to an Apple Engineer about this and they suggested the best way was to make your container return either an NSPersistentContainer or NSPersistentCloudKitContainer depending on whether you users have selected iCloud syncing internally in your app - you can use a UserDefaults bool to store this.This works because NSPersistentCloudKitContainer is a subclass of NSPersistentContainer.You will also need to set the NSPersistentHistoryTrackingKey to true on the vanillla container so changes are recorded should they switch iCloud back on. There doesn't appear to be any need to set any options manually on NSPersistentCloudKitContainer as they're enabled by default.I have a PersistenceService class which manages my MOC and in it, this is how I set up the container: static var iCloudSyncData = UserDefaults.standard.bool(forKey: iCloudSyncData) static var persistentContainer: NSPersistentContainer = { let container: NSPersistentContainer? if iCloudSyncData { container = NSPersistentCloudKitContainer
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags:
NSPersistentCloudKitContainer only supports the private database and the public database. If you want to let your users share data with each other, you need to use the CKShare and CK operations API.
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags:
You might want to check if this post answers your question. SwiftData + CloudKit uses NSPersistentCloudKitContainer under the hood, and so the content applies. Best, —— Ziqiao Chen Worldwide Developer Relations.
Topic:
App & System Services
SubTopic:
Widgets & Live Activities
Tags:
Agreed, I read the docs to mean that sharing is possible but I’m not able to use NSPersistentCloudKitContainer methods that return CKRecords based on managed objects at this time. I am hoping this is just due to early beta issues.
Topic:
App & System Services
SubTopic:
Core OS
Tags:
NSPersistentCloudKitContainer does not support unique constraints. instead allow it to import all records and resolve the conflicts yourself or migrate the data to another store file which more accurately models your constraints.
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags:
@Engineer Hi, Sorry for many questions - still can't figure out why crash happens in widget extension. I was curious, if it can be connected to the usage of NSPersistentCloudKitContainer? Would appreciate any help of advice. Thanks in advance!
Topic:
Developer Tools & Services
SubTopic:
Xcode
Tags:
In the CloudKit environment, duplicates can indeed happen if multiple peers can create the same data. We discuss this topic in Remove duplicate data. (As of today, SwiftData + CloudKit integration uses NSPersistentCloudKitContainer, and so the content applies.) Regarding CloudKit public database, yeah, it fits the use case where any user can generate data and all users can read the data. However, SwiftData + CloudKit public database integration is not supported today. You probably need to stick with NSPersistentCloudKitContainer if to use CloudKit public database. Best, —— Ziqiao Chen Worldwide Developer Relations.
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags:
You would need to mark the zone as user-purged for the DefaultStore to obey an out of band delete. Alternatively you can use NSPersistentCloudKitContainer to manage CloudKit sync on the side through Coexistence and use its purge APIs.
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags:
I added a new Core Data model version, introducing a new entity. Based on the naming of the Entity I get different behaviour: A: If the entity is alphabetically ordered as last entity: Everything works fine. B: There entity is ordered before already existing entities: All records of these existing entities get a new CloudKit id. Resulting in duplicated data and broken relations. In some cases the seem-to-be new insert of these records causes the migration to fail. (Constraint unique violation, reason=constraint violation during attempted migration) My only workaround so far is to just give the entity a different name, to appear last in the list. __ Does anyone else experience this issues? I am not sure if my code could be able to trigger this kind of behaviour. I will try to reproduce it in an empty project, to file a bug report.
What is the expected / best strategy to migrate a synced Core Data model to a new version? The issue: A new app version with a new Core Data model introducing new attributes or entities. DeviceA installs the update and edits data with new values and creates new entities. DeviceB is still used and downloads these changes. The unknown attributes and entities are ignored, but the HistoryTracking gets updated. A few days later DeviceB gets the update. The missing attributes and entities are not downloaded, as the history is up to date. __ The issue exists with iOS 13, I hoped for iOS 14 to introduce a strategy. I tried with the first iOS 14 beta, but it is at least not handled automatically. From the visible API changes I don't see a way to handle this specifically. Not sure if the talks will reveal anything about it. Will apply for a lab session and would like to get as much input to prepare before that might take place.
Once I have the path, I plan to do this.lazy var persistentContainer: NSPersistentCloudKitContainer = { let container = NSPersistentCloudKitContainer(name: “MyAppName”) // Create a store description for a CloudKit-backed local store let cloudStoreLocation = URL(fileURLWithPath: Original or Ubiquity Path) let cloudStoreDescription = NSPersistentStoreDescription(url: cloudStoreLocation) cloudStoreDescription.configuration = Cloud // Set the container options on the cloud store cloudStoreDescription.cloudKitContainerOptions = NSPersistentCloudKitContainerOptions( containerIdentifier: com.my.container) // Update the container's list of store descriptions container.persistentStoreDescriptions = [ cloudStoreDescription, ] // Load store container.loadPersistentStores { storeDescription, error in guard error == nil else { fatalError(Could not load persistent stores. (error!)) } } return container}()
Topic:
App & System Services
SubTopic:
iCloud & Data
Tags:
struct PersistenceController { static let shared = PersistenceController() let container: NSPersistentCloudKitContainer init() { container = NSPersistentCloudKitContainer(name: MJ) guard let fileContainer = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: group.com.Jad.MJ)?.appendingPathComponent(MJ.sqlite) else { fatalError(Shared file container could not be created.) } let storeDescription = NSPersistentStoreDescription(url: fileContainer) storeDescription.setOption(true as NSNumber, forKey: NSPersistentHistoryTrackingKey) storeDescription.setOption(true as NSNumber, forKey: NSPersistentStoreRemoteChangeNotificationPostOptionKey) storeDescription.cloudKitContainerOptions = NSPersistentCloudKitContainerOptions(containerIdentifier: YOUR containerIdentifier) container.persistentStoreDescriptions = [storeDescription] container.loadPersistentStores(completionHandler: { (storeDescription, error) in if let error = error as NSError? { fatalError(Unresolved error (error), (er
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: