Reputation: 3699
According to the release notes, Xcode 9 adds support for fetched indexes:
"The data model editor presents a unified interface for Core Data’s new fetch indexes feature as well as its existing property index and entity compound index features. Older data models are translated into fetch index form for editing, and saved to the old file format when necessary. Compiling a data model with a Deployment Target lower than iOS 11, watchOS 4, macOS 10.13, or tvOS 11 continues to generate a compatible compiled form. (30843153)"
My project has Deployment Target set to iOS 9 at the moment a yet I can't compile my CoreData model, it gives me the following errors for every entity that has a compound index set:
Model.xcdatamodeld/Model.xcdatamodel:MyEntity|compoundIndex[0]: error: Expression requires a concrete result type.
Model.xcdatamodeld/Model.xcdatamodel:MyEntity|compoundIndex[0]: error: Expression attributes are not compatible with the current deployment target.
Model.xcdatamodeld/Model.xcdatamodel:MyEntity|compoundIndex[1]: error: Expression requires a concrete result type.
Model.xcdatamodeld/Model.xcdatamodel:MyEntity|compoundIndex[1]: error: Expression attributes are not compatible with the current deployment target.
Model.xcdatamodeld/Model.xcdatamodel:MyEntity: error: Fetch Indexes feature requires iOS deployment target 11.0 or later
Model.xcdatamodeld/Model.xcdatamodel:MyEntity: error: Fetch Indexes feature requires Xcode 9.0 tools or later
Any idea how to fix the build error?
UPDATE:
Xcode 9 correctly converts compound indexes into fetch indexes for all cases except those created from relationships, as noted in the "Known Issues" section:
The data model editor only supports creating fetch indexes from attributes and expressions in this beta, not from relationships. (32407895)
The affected fetch indexes look like this and the only attributes can be selected from the dropdown menu:
However, there's no workaround described in the document.
Upvotes: 7
Views: 2852
Reputation: 4928
I came here after getting
cdtool[0] Entity already has an index with name
While trying to upgrade base target to iOS 11.
After days of trial and error, the fix was to rename the index using a unique name
Prior to iOS 11 index names weren't unique, so I had 2 byRankIndex. Changing them to unique names fixed it.
Upvotes: 0
Reputation: 11143
I just ran into this issue in the Xcode 9 GM. What I observed was that unchecking the Ascending
checkbox in the index editor caused this error to occur (it was only showing up after I made a new index). I am assuming that adjusting this index attribute is only supported in the iOS 11 fetch indexes (you'll notice any index you made prior to Xcode 9 are listed as ascending by default).
TL;DR: Make sure the Ascending
checkbox is checked for all properties in the fetch index editor.
Upvotes: 3
Reputation: 638
I've filed a bug with Apple - as there doesn't seem to be a good fix. For now, I've changed the "Tools Version" from Automatic/Xcode 9 to Xcode 8. That fixed my problem until the bug is fixed.
Its also possible that some Models simply aren't compatible with the new indexes. In my case, it was subclassed models (i.e. from abstract classes) that had relationships to other types. For example:
PIFolder
|
|-----PIFolderProject -> index: defaultItem (task relationship)
|-----PIFolderNotebook-> index: defaultItem (note relationship)
Upvotes: 0
Reputation: 3699
This is fixed in Xcode 9 beta 2, according to the release notes:
The Xcode data model editor supports creating fetch indexes from attributes, expressions, and relationships. (32407895)
Upvotes: 0