35

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?

2 Answers 2

88

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

2
  • 14
    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...
    – m8labs
    Jul 29, 2018 at 14:01
  • 2
    @m8labs thanks for that ! i was puzzled about the "Undefined" column that i coudln't change. Xcode really never ceases to amaze me.
    – Ben G
    Jan 12, 2019 at 10:34
10

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.

5
  • 9
    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/…).
    – Martin
    Oct 19, 2017 at 15:08
  • 7
    You don't have time but you want someone else to take the time for you? Oct 19, 2017 at 15:46
  • 5
    Ahah, good point. I though you already had the answer when you posted. But thanks for providing the link ;)
    – Martin
    Oct 19, 2017 at 16:36
  • 4
    New indexing API is discussed at this point in the video: developer.apple.com/videos/play/wwdc2017-210/?time=628
    – stephent
    Nov 2, 2017 at 20:08
  • Thanks for the link to the video. For those not interested in spotlight, just start at around the 10 minute mark. Feb 2, 2019 at 19:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.