CloudKit - Cannot create or modify field 'CD_nameFirstChar' in record 'CD_Charts' in production schema

Some of my users are reporting an inability to sync via CloudKit between devices. I have not seen it on any of my devices, but one user got me some console logs that are showing the following error:

<CKError 0x600000a0f840: "Partial Failure" (2/1011); "Failed to modify some records"; uuid = EDC7B3E3-02F8-43B7-83B6-22D17EF0442A; container ID = "iCloud.cribaudo.iphemeris"; partial errors: { C611E11F-3DC0-484C-8FC1-23473062D9D0:(com.apple.coredata.cloudkit.zone:defaultOwner) = <CKError 0x600000a04660: "Invalid Arguments" (12/2006); server message = "Cannot create or modify field 'CD_nameFirstChar' in record 'CD_Charts' in production schema"; op = D83EF1F7DD772042; uuid = EDC7B3E3-02F8-43B7-83B6-22D17EF0442A>

I do not understand this:

  • The field CD_nameFirstChar was added to the data model in the version 15.
  • Automatic Migration is enabled.
  • The CloudKit Console says the Private Database Container being used by my App is deployed to production.
  • The entity CD_Charts (I only have one) that is deployed to production shows that field as present (CD_nameFirstChar).
  1. Why would this user be getting this error? As far as I can see they are running a version where migration to Model 15 should have been triggered at some point in the past.

  2. If somehow something went wrong with their migration, how would I fix it?

Any thoughts / ideas are appreciated.

One thing I should add is that the migration from Model 14 to 15 was not lightweight. I did use:

@interface ModelMigration14to15 : NSEntityMigrationPolicy
-(NSString *)nameFirstChar:(NSString *)name;
@end

And I used a MapModel14to15 which used the above function to set the value of nameFirstChar. The Value Expression for that attribute is:

FUNCTION($entityPolicy,` "nameFirstChar:" , $source.name) 

from the above mentioned NSEntityMigrationPolicy class.

This worked ok on all my devices and apparently on some user devices. This issues seems to effect only a small subset of my users but not all? So I am at a loss to understand why this would happen or how to fix it.

Answered by Frameworks Engineer in 784707022
Accepted Answer

The CloudKit Console says the development schema and which has the field nameFirstChar field is indicated as deployed to production. However I DO NOT see it over on the production side. See the images. How is this possible and or what am I missing? The data is syncing just fine on all my devices and perhaps some users ... I think. And I ran this code at various points to deploy development to production:

    func initializeCloudKitSchemaForNewModel()
    {
        coreDataLogger.log("*** Initialize CloudKit Scheme for New Model - Start")
        if(!useiCloud) { return }
        do {
            // Use the container to initialize the development schema.
            let options = NSPersistentCloudKitContainerSchemaInitializationOptions()
            try pc.initializeCloudKitSchema(options:options)
        }
        catch {
            coreDataLogger.error("*** CoreDataUtil Initializing new schema: \(error)")
        }
        coreDataLogger.log("*** Initialize CloudKit Scheme for New Model - End")
    }

CloudKit - Cannot create or modify field 'CD_nameFirstChar' in record 'CD_Charts' in production schema
 
 
Q