nofelmahmood / Seam

Seamless CloudKit Sync with CoreData
https://medium.com/@Nofel/reason-why-cloudkit-cannot-be-ignored-9c7806d76230
MIT License
669 stars 64 forks source link

Getting NSInternalInconsistencyException #22

Closed Jamie-Wallace closed 7 years ago

Jamie-Wallace commented 9 years ago

Hi Nofel

I seem to have everything setup but when I launch my app I am getting the following exception:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Entity already contains a property named sm_LocalStore_RecordID.'

It looks like it is happening in:

func addExtraBackingStoreAttributes(toEntity entity: NSEntityDescription)

line:

 entity.properties.append(recordIDAttribute)

Have you any ideas why this may be happening?

Just a little bit more background as my setup wasn't too straightforward.

I'm using the framework in an Objective C app - and struggled to get it to link using CocoaPods. So for now I've just copied in your Swift code files and accessing the Swift via #import "ProjectName-Swift.h"

This is how I am adding the Store Type.

 smStore = [coordinator addPersistentStoreWithType:SMStore.type configuration:nil URL:storeUrl options:nil error:nil];

(I had to use SMStore.type directly as I couldn't get at SeamStoreType)

Any help or pointers would be much appreciated. Thank you

gumbright commented 8 years ago

This is exactly what I am seeing now with the latest (7/13/16) master. I will take a look at that commit.

gumbright commented 8 years ago

Guessing the issue here is that it adds the property to an abstract entity, then tries to do it to the child(or some combination where it tries to add the same thing to child and parent). That is what is happening to me. I have an abstract entity ImageData with two children, PhotoData and ThumbnailData. Going to try having it skip attract entities.