Why Xcode does not show index options for CoreData entities and attributes?
Asked Answered
W

2

36

In Xcode 9 (beta 6) indexing options are missing in Data Model Inspector (.xcdatamodeld file):

enter image description here enter image description here

They are visible in Xcode 8:

enter image description hereenter image description here

Do you know what reasons are behind this decision?

Whereby answered 28/8, 2017 at 15:17 Comment(0)
E
89

As @tomharrington said, the solution is in the WWDC 2017 video: Indexing stuff begins at 10:32 and the demo at 16:40.

It's still possible to create and index via Xcode9:

  • First, select your entity, long-click on the + (Add Entity), and select Add Fetch Index.

first step

  • Then, name your index appropriately, the select the property you want to index on (and choose ascending or descending, depending on how is organized your data) second step

  • Finally, as explained on the video, this will not trigger a migration and user that update your app will not get your index. If you want to force a model migration, add an Hash Modifier by selecting the entity, and setting Right Panel > 3rd tab > Versioning > Hash Modifier. optionally, third step

Esther answered 20/10, 2017 at 8:40 Comment(2)
You should probably to mention the need of choosing "Type" for index, instead of just leaving it "Undefined", but Xcode doesn't allow to do it, unless you choose "Type" first, and "Property" after. Also Xcode can crash there. What a wonderful piece of software...Afra
@Afra thanks for that ! i was puzzled about the "Undefined" column that i coudln't change. Xcode really never ceases to amaze me.Mandrake
M
9

Simple indexing is deprecated in iOS 11, and the Xcode 9 UI reflects that. This is from the docs for NSPropertyDesciption:

isIndexed deprecated

At WWDC 2017 the What's New in Core Data session described a new indexing API. Give that session a look.

Misquote answered 28/8, 2017 at 15:33 Comment(6)
Could you give a clue of what to do instead? No time for now to watch 35' video to just add a dumb index (I know I should watch it later). Of course Apple did not document the property which seems related to the new API (developer.apple.com/documentation/coredata/nsentitydescription/…).Esther
You don't have time but you want someone else to take the time for you?Misquote
Ahah, good point. I though you already had the answer when you posted. But thanks for providing the link ;)Esther
New indexing API is discussed at this point in the video: developer.apple.com/videos/play/wwdc2017-210/?time=628Choong
Thanks for the link to the video. For those not interested in spotlight, just start at around the 10 minute mark.Cracking
It seems that the video is no longer on WWDC website. It's still on youtube though.Aubrette

© 2022 - 2024 — McMap. All rights reserved.