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).
-
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.
-
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.