Swift Data Error "The model configuration used to open the store is incompatible with the one that was used to create the store."

615 views Asked by At

While developing an iOS app with Xcode Beta 14 I changed a swift-data model and I started getting this error:

Error Domain=NSCocoaErrorDomain Code=134020 "The model configuration used to open the store is incompatible with the one that was used to create the store." UserInfo={NSAffectedObjectsErrorKey=<NSManagedObject: 0x6000021a9680>

I deleted the app from the device and re built and ran the app. I still got the same error. Now even after rolling back to the previous model version I still get the error, even on different simulators and after deleting the app.

I've tried reverting the model and reinstalling it and I consistently get the error.

This is the schema of the store:

Schema
schemaEncodingVersion: 1.0
encodingVersion: 1.0
entities:
 Entity - name: DLDrive, mangledName: 14DriveLoggerKit7DLDriveCm, superEntity: nil)
  subentities:
  storedProperties:
    Attribute - name: id, options: 1, valueType: String, defaultValue: nil, hashModifier: nil
    Attribute - name: startTime, options: 0, valueType: Date, defaultValue: nil, hashModifier: nil
    Attribute - name: endTime, options: 0, valueType: Date, defaultValue: nil, hashModifier: nil
    Attribute - name: startLocationName, options: 0, valueType: String, defaultValue: nil, hashModifier: nil
    Attribute - name: endLocationName, options: 0, valueType: String, defaultValue: nil, hashModifier: nil
    Attribute - name: sunsetTime, options: 0, valueType: Date, defaultValue: nil, hashModifier: nil
    Attribute - name: sunriseTime, options: 0, valueType: Date, defaultValue: nil, hashModifier: nil
    Attribute - name: routeData, options: 0, valueType: Optional<Data>, defaultValue: nil, hashModifier: nil
    Attribute - name: startLocationData, options: 0, valueType: Optional<Data>, defaultValue: nil, hashModifier: nil
    Attribute - name: endLocationData, options: 0, valueType: Optional<Data>, defaultValue: nil, hashModifier: nil
    Attribute - name: weatherStore, options: 0, valueType: Optional<Data>, defaultValue: nil, hashModifier: nil
  inheritedProperties:
  uniquenessConstraints:
    ["id"]

In the error it logs this as the model it's trying to save:

error saving model context Error Domain=NSCocoaErrorDomain Code=134020 "The model configuration used to open the store is incompatible with the one that was used to create the store." UserInfo={NSAffectedObjectsErrorKey=<NSManagedObject: 0x60000217c820> (entity: DLDrive; id: 0x6000002f9040 <x-coredata:///DLDrive/tDBD30926-8298-4666-B224-0A20452E38D42>; data: {
    endLocationData = nil;
    endLocationName = Waterloo;
    endTime = "2023-07-24 22:29:00 +0000";
    id = "74CBAF1C-6068-4155-8D91-0E8FA09FBE36";
    routeData = nil;
    startLocationData = nil;
    startLocationName = Wichita;
    startTime = "2023-07-24 22:10:09 +0000";
    sunriseTime = "0001-01-01 11:27:02 +0000";
    sunsetTime = "0001-01-02 00:45:02 +0000";
    weatherStore = nil;
})}
0

There are 0 answers