Search results for

NSPersistentCloudKitContainer

589 results found

Post

Replies

Boosts

Views

Activity

NSCloudKitMirroringExportRequest issues
I'm attempting to create a Swift/SwiftUI app that will run on iOS/iPadOS that uses CloudKit to syncronize data between devices. I have created the App in Xcode.In the Apps Signing & Capabilities tab, I have:- Ensured that the Bundle Identifier is valid- Added the iCloud capability - Created the Container and checked it - Validated that the Container was created in the CloudKit Dashbaord- Added the Backgrouind Modes capability - Checked the Remote notifications optionI have modified/validated AppDelegate.swift:- Validated that it is using NSPersistentCloudKitContainer- Added container.viewContext.automaticallyMergesChangesFromParent to true- Added container.viewContext.mergePolicy to NSMergeByPropertyObjectTrumpMergePolicyWhen I load the App, I get a series of errors reported related to CloudKit NSCloudKitMirroringExportRequest. These errors are shown below. I am able to create records, but can see they are only stored locally and do not get synced to the CloudKit Dashboard - interestingly enough,
21
0
14k
Apr ’23
Reply to NSFetchedResultsController use-after-free issues in iOS 16.1
Yup! I am suddenly seeing a lot of crash reports (over 100 in the last couple of days) and ALL from users on iOS 16.1. This is new and nothing in that part of the App changed. Crashing right after the CoreData is initialized and NSPersistentCloudKitContainer is ready. At that point the controller does a fetchRequest for items in the Table and Crash with some kind of memory error. In my case it is simply making a request for items sorted alphabetically?!
Topic: App & System Services SubTopic: Core OS Tags:
Dec ’22
Getting errors when trying to connect to CloudKit using NSPersistentCloudKitContainer
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:<
5
0
7.4k
Nov ’22
Reply to Logger messages not showing in XCode console
@eskimo I am using Logger (OSLog) and I don't want debug messages from frameworks like mentioned below. What should I do to achieve that? When I use CoreData / CloudKit especially NSPersistentCloudKitContainer I do see a lot of debug messages such as the ones below: CoreData: debug: CoreData+CloudKit: -[PFCloudKitOptionsValidator validateOptions:andStoreOptions:error:](36): Validating options: containerIdentifier: databaseScope:Private ckAssetThresholdBytes: operationMemoryThresholdBytes: useEncryptedStorage:NO useDeviceToDeviceEncryption:NO automaticallyDownloadFileBackedFutures:NO automaticallyScheduleImportAndExportOperations:YES skipCloudKitSetup:NO preserveLegacyRecordMetadataBehavior:NO useDaemon:YES apsConnectionMachServiceName: containerProvider: storeMonitorProvider: metricsClient: metadataPurger: scheduler: notificationListener: containerOptions: defaultOperationConfiguration: progressProvider: test_useLegacySavePolicy:YES archivingUtilities: bypassSchedulerActivityForInitialImport:NO stor
Topic: App & System Services SubTopic: Core OS Tags:
Nov ’22
SwiftUI macOS app not syncing with iCloud
I have an iOS and iPadOS app that use iCloud to sync. They are in the App Store and the database was pushed to production. They work as advertised. I wrote also a macOS app that uses Cloudkit, the container it set as NSPersistentCloudKitContainer and the merge policies are set ok. I also checked that the profile for the app and certificates are good to go, as well as the permissions of the app. Apple signed the app, but, it doesn't sync with iCloud and I can't figure out why. I checked iCloud on my Mac and the app is there, set to be syncing. I have already read a few articles and have tried all the possible solutions, including signing out and back in, rebuilding the app, etc. One thing, thought, when I delete an item, the app takes sometime to react to it, as if it's trying to connect. I tried with TCPDump, and other things to check for connection issues, but I can't find that app trying to connect. I took a few screenshots of the different configs, etc so you can see as well, but has anyone run in
2
0
2.1k
Nov ’22
CoreData with CloudKit on watchOS
Hello,I have managed to get CoreData with CloudKit working with the new NSPersistentCloudKitContainer on the iOS version of my app and got it to automatically sync while the app is running. However, when I went to set things up on the watchOS app, I noticed that a sync will only occur if I force close and reopen the watch app.The following scenarios workUser has both the watchOS app and iOS app runningUser makes a change to the data on the watch appThe change is reflected on the iOS appUser has only the iOS app runningUser makes a change to the data on the iOS appThe user opens the watchOS app from terminatedThe changes are reflected on the watchOS appThe following scenario does not workUser has the watchOS app running and the iOS app runningUser makes a change to the data on the iOS appNo change every makes it through to the watchOS app, even after waiting a long timeOnly if I force close the app and restart does a sync occurIn the cases were a sync is successful I see the following logs correctly:C
3
0
1.7k
Sep ’19
CloudKit - How to use Configurations to properly segregate public and private data
I am trying to understand the concepts between two of the CloudKit code samples: CoreDataCloudKitDemo, which shows sync between CoreData and CloudKit CoreDataFetchedProperty which shows how you can keep public and private data in two CoreData configurations and join them together. After some trial and error I created a single NSPersistentCloudKitContainer that I thought used the two separate configurations - each had it's own local persistent store, database scope was set properly for both stores, etc. But when I run the app it complained of the following: Failed to load persistent stores:Error Domain=NSCocoaErrorDomain Code=134060 A Core Data error occurred. UserInfo={NSLocalizedFailureReason=CloudKit integration does not allow relationships to objects that aren't sync'd. The following relationships have destination entities that not in the specified configuration. EntityA: entityB - EntityB So, I went back to the model and although I had created two separate Configurations (with EntityA in one and
2
0
1.3k
Oct ’22
Reply to 0xdead10cc & NSPersistentCloudKitContainer
HI, Asking for more background time doesn't feel like a solution, that will just postpone the crash. Actually, that is the answer, at least partly. The reason this can't really happen: In my naiveté I assumed that NSPersistentCloudKitContainer and Core Spotlight would release any locks when app is suspended. ...is that the system can't really know in advance what you're going to ask it to do. They actually take out some of their own tasks, but that doesn't really help if the suspension process is starting at roughly the same time you're asking them to do work. That solution here is to create your own background task for the larger job that you're trying to finish (Add some stuff to my CoreSpotlight index) and end it once the work is done. -Kevin Elliott DTS Engineer, CoreOS/Hardware
Oct ’22
0xdead10cc & NSPersistentCloudKitContainer
We're receiving crash reports where our app is killed by the system because of 0xdead10cc. If I understand correctly this is happening because our app has a file lock or SQLite database lock. Our app is using NSPersistentCloudKitContainer and is indexing the data to Core Spotlight. In my naiveté I assumed that NSPersistentCloudKitContainer and Core Spotlight would release any locks when app is suspended. What is the best way to solve this? Asking for more background time doesn't feel like a solution, that will just postpone the crash.
1
0
1.3k
Oct ’22
Core Data + CloudKit - data record type does not appear in CloudKit Dashboard
I created a blank SwiftUI project and included Core Data and Cloud Kit. By selecting Core Data and CloudKit while creating the project, Apple already included some Core Data sample code and entities in the project, and also a Persistence.swift file that contained NSPersistentCloudKitContainer code. The sample code included a SwiftUI list in ContentView, with an Add button to add timestamp to the list when pressing. **I suppose after some basic setup to the project and created the CloudKit container, the app data will auto sync and can be viewed in CloudKit dashboard, but it didn't. ** Here is what I have setup: Created the project with Core Data and Cloud Kit Haven't touch any code from the Persistence.swift file since Apple has already set it up. Also haven't touch the app struct, content view and core data entities (left all sample code untouched) Selected Automatically Manage Signing and Development Team, with a paid developer acc. Added iCloud Capability Selected CloudKit in iCloud Capability, Cr
2
0
1.8k
Oct ’22
Can I use NSPersistentCloudKitContainer while at the same time adding extra fields to my CloudKit CKRecord?
For example, because NSPersistentCloudKitContainer doesn't support ordered relationship, I'd like to have an array of references on my CKRecord because CloudKit support NSArray field type; I can then sync these array manually (e.g. persist without relying on Core Data). Is it okay or recommended to do so?
1
0
1.1k
Sep ’22
Reply to Can I use NSPersistentCloudKitContainer while at the same time adding extra fields to my CloudKit CKRecord?
hi, my guess is that you're playing with fire if you go behind NSPersistentCloudKitContainer's back (!) if you want to keep the notion of an ordered set for a relationship among two entities that is A <---->> B (many B entities associated with an A, but only one A entity is associated with a given B), then two options come to mind (and these can be handled directly on the Core Data side). first, add an integer attribute to B to indicate its relative position among all its sibling B objects. if A changes the order of the B objects, just rewrite the position of each (or as may as needed) associated B. second ... perhaps if each B object represents lots of data and you think it an expensive operation to rewrite many B objects when reordered ... then consider adding an intermediate entity C with one integer attribute (perhaps named position) and two relationships: one from C to A (many-to-one) and one from C to B (one-to-one), so that you have A <---->> C <----> B. in essence, eac
Sep ’22
How to read/write to App1’s database from App2?
I have 2 apps in the App Store, and each uses the private database in its own CloudKit container. (ie, App1 uses “iCloud.com.company.App1” and App2 uses “iCloud.com.company.App2”) I want to add a feature to App2 which will require App2 to read/write to the App1 database. To be clear, we’re talking about 2 apps, 2 private databases, but all access occurs under the same user’s AppleID. In App2, I’ve tried to create 2 NSPersistentCloudKitContainers - one for each App’s database as follows: @main struct App2: App { @StateObject var app1DB = PersistenceApp1.shared @StateObject var app2DB = PersistenceApp2.shared @SceneBuilder var body: some Scene { WindowGroup { NavigationView { ContentView() .environmentObject(app1DB) .environmentObject(app2DB) } } } } …where each Persistence object is defined like this… class PersistenceApp1: ObservableObject { static let shared = PersistenceApp1() let container: NSPersistentCloudKitContainer init(inMemory: Bool = false) { container = NSPersistentCloudKitContainer
2
0
1.3k
Sep ’22
Reply to How to read/write to App1’s database from App2?
OK, I've solved my issue. 1st of all, defining 2 NSPersistence : ObservableObjects most definitely wasn't the way to go: @StateObject var app1DB = PersistenceApp1.shared @StateObject var app2DB = PersistenceApp2.shared I just needed one: @StateObject var persistence = Persistence.shared deeje's answer pointed me in the right direction, but what was still missing for me were the following 3 key ideas: container's name: is just the name of the .xcdatamodeld - and that this has nothing to do with what I expected (ie, that it was somehow related to my CloudKit container ids “iCloud.com.company.App1”) container = NSPersistentCloudKitContainer(name: Model) Within Model.xcdatamodeld I needed to define 2 separate configurations - with each configuration holding the Entities that are held within the the CloudKit containers: App1Config - holds the Entity from iCloud.com.company.App1, and App2Config - holds the Entity from iCloud.com.company.App2 I needed 2 store descriptions for each app, and to specify the sq
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’22
Reply to How to read/write to App1’s database from App2?
use NSPersistentCloudKitContainerOptions to configure the container identifier to sync with class PersistenceApp1: ObservableObject { static let shared = PersistenceApp1() let container: NSPersistentCloudKitContainer init(…) { container = NSPersistentCloudKitContainer(name: “App1”) let store = NSPersistentStoreDescription() store.cloudKitContainerOptions = NSPersistentCloudKitContainerOptions(containerIdentifier: iCloud.com.example.App1) container = [store] container.loadPersistentStores… } … } Also, make sure to add both container identifiers to your app's Signing & Capabilities > iCloud > Containers list
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’22