Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"In the uniqueness constraints attribute for entity, comma is not valid property" in Coredata Xcode 8

I created a database with Core Data on iOS. I initially set up a unique constraint in my Conversation entity. However, after removing it, I was getting an error: "In the uniqueness constraints attribute for entity Conversation, comma is not a valid property".

I looked at every field in my DataModel.xcdatamodeld but could not find any solution.

enter image description here

like image 921
M Swapnil Avatar asked Aug 31 '25 22:08

M Swapnil


2 Answers

If you have set any constrains (using Attribute name) previously for your Entity and later if you would have deleted/renamed that particular attribute, then it will throw such error. You need to rename or delete that constraint property by double clicking it with respect to your data model business flow.

Refer screenshot for reference.

enter image description here

like image 154
Mithun Ravindran Avatar answered Sep 03 '25 14:09

Mithun Ravindran


I had the same issue with Xcode 8.1. I did not want to delete all the many attributes painfully set up on all 6 of my entities, and found another solution. Let's assume your model file is called "foobar.xcdatamodeld".

  1. Edit the XML directly in the model. For this, you need to get to the file 'contents' inside the model file. The path to it is: foobar.xcdatamodeld/foobar.xcdatamodel/contents. To get to it in Finder, control-click on the "xcdatamodeld" package to "Show Package Contents", then again on the "xcdatamodel" package. You can then drag the file 'Contents' into your text editor of choice. You will see the constraints appear as follows in the XML:

    <uniquenessConstraints>
        <uniquenessConstraint>
            <constraint value="property_name"/>
        </uniquenessConstraint>
    </uniquenessConstraints>
    

You can edit "property_name" to match the new value, or remove the constraints altogether.

  1. Once edited, try to clean and recompile. In my case, the error was still there, so I had to do a little "renaming dance" with Xcode. I deleted the model from the Xcode project, then renamed the model file to a different name (including the "xcdatamodel" file inside the "xcdatamodeld" file), and added it back to Xcode. I repeated that again with the old name again so I was back to the initial name.
like image 30
charles Avatar answered Sep 03 '25 12:09

charles