Hi folks
I have a SwiftUI app that I have distributed to my testers. I have deployed my development schema to production cleanly and I have also tested with com.apple.developer.icloud-container-environment in entitlements set to "Production". However what I am finding is that when I compile and run the app via Xcode, all is well. My test devices and simulators are sharing the data as I'd expect, in both the development and production private and public databases.
However, when I package it up, I've tried manual and automatic signing, and release it through TestFlight and load it into the same physical devices that previously worked via Xcode, no syncing occurs, it just seems to write to local store.
Then when I connect to Xcode and rerun the app, overwriting the TestFlight version (i.e. I'm not deleting the local store, just the app) the records I created with the TestFlight version will now make their way to the Production database.
I am guessing that I have goofed somewhere along the line with certificates, but I have recreated new provisioning profiles and new certificates - I admit I find this part confusing, I'm quite new to this - but to no avail. I've read through the documentation and searched the web, but I'm not getting any leads. Any suggestions on what I am doing wrong would be gratefully received.
Thanks
Post
Replies
Boosts
Views
Activity
Hi All
I am hitting an issue when developing an app that uses the CloudKit Public DB. I am relatively new to this, and I may be doing something wrong. I have distilled the issue to use just the template app that comes when you create a new Core Data with iCloud app, and detailed the steps below. My question is basically, am I doing something stupid? If I'm not then seems likely it's a bug in Xcode and I'll just have to wait.
In a nutshell, syncing to the public DB works for the first run of the app only. Stopping and restarting the app seems to throw errors and cause the mirroring delegate to fail.
Step by simple step, I can recreate my issue with this:
Create App with Use Core Data and Host in ICloud - interface is SWiftUI
In project signings and capabilities add iCloud and Background Modes
In nearly appeared iCloud section enable Cloudkit and choose or create a container
In newly appeared Background Modes section enable Remote Notifications
In persistence.swift add :
import CloudKit
Still in persistence.swift add the following:
guard let description = container.persistentStoreDescriptions.first else
{
fatalError("Something bad happened")
}
description.cloudKitContainerOptions?.databaseScope = .public
I have added the above just before the following line:
container.loadPersistentStores(completionHandler: { (storeDescription, error) in
In he schema model, highlight the default configuration and check in the data model inspector that "use cloudkit" is checked
Run the app and hit the + a few times to add some records.
Check on Cloudkit Dashboard in the public database in the container selected / created in step 3 after I created indexes on recordName / modifiedTimestamp in order to view the records on the CD_Item entity. Unfortunately, my Cloudkit Dashboard seems to have changed. Whereas before I could click Indexes and then add the recordName (queryable) / moodifiedTimestamp (queryable / sortable), I don't seem to be able to select these fields anymore - but that's another issue. Luckily I had created the indexes a while back and after a minute or so all appear in the public database. No errors are reported in the console window on Xcode.
Stop and restart the app.
This time when I click the plus button, the timestamp records are not being uploaded to the public DB (though they do appear on the screen) and the console is reporting error messages similar to that below:
CoreData: CloudKit: CoreData+CloudKit: -NSCloudKitMirroringDelegate _finishedRequest:withResult:: Finished request: <NSCloudKitMirroringExportRequest: 0x283666bb0> 9F190C45-7713-4ACE-96DB-867D99FF62ED with result: <NSCloudKitMirroringResult: 0x2838b9e20> success: 0 madeChanges: 0 error: Error Domain=NSCocoaErrorDomain Code=134406 "Request '9F190C45-7713-4ACE-96DB-867D99FF62ED' was aborted because the mirroring delegate never successfully initialized due to error: <CKError 0x2836aba50: "Partial Failure" (2/1011); "Failed to modify some record zones"; uuid = 3F399390-1F10-4198-BBBF-F3BD76E99591; container ID = "iCloud.XXXXXXXXXXX"; partial errors: { com.apple.coredata.cloudkit.zone:defaultOwner = <CKError 0x2836a5290: "Server Rejected Request" (15/2027); server message = "Custom zones are not allowed in public DB"; op = 943153DA6AC169A1; uuid = XXXXXXXXXXXXXXXXXXXXXXXX> }>" UserInfo={NSLocalizedFailureReason=Request '9F190C45-7713-4ACE-96DB-867D99FF62ED' was aborted because the mirroring delegate never successfully initialized due to error: <CKError 0x2836aba50: "Partial Failure" (2/1011); "Failed to modify some record zones"; uuid = 3F399390-1F10-4198-BBBF-F3BD76E99591; container ID = "iCloud.XXXXXXXXX"; partial errors: { com.apple.coredata.cloudkit.zone:defaultOwner = <CKError 0x2836a5290: "Server Rejected Request" (15/2027); server message = "Custom zones are not allowed in public DB"; op = 943153DA6AC169A1; uuid = XXXXXXXXXXXXXXXXXXXXXXXXX> }>}
Thanks in advance for any assistance anyone can offer,
Ian