Hi everyone,
I'm trying to add standard, non-unique database indexes to my Core Data entities for performance optimization (e.g., indexing Date or String attributes used in predicates and sort descriptors). I'm using Xcode 16.2 on macOS Sequoia 15.1.
My problem is that I cannot find the expected UI element in the Core Data model editor (.xcdatamodeld) to configure these database indexes.
What I Understand / Expect:
I know the old "Indexed" checkbox on the Attribute Inspector is deprecated/gone. My understanding from recent documentation and tutorials is that database indexing (separate from Spotlight indexing) should be configured in the Entity Inspector (when the Entity itself is selected), within a section titled "Indexes" (usually located below "Constraints"). This "Indexes" section should allow adding individual or compound indexes that translate to SQL CREATE INDEX commands, distinct from uniqueness constraints.
What I'm Experiencing:
When I select an Entity in the model editor, the "Indexes" section is completely missing from the Data Model Inspector pane on the right. I see sections for Name, Class, Constraints, Spotlight, User Info, Versioning, etc., but no "Indexes" section appears between Constraints and Spotlight (or anywhere else).
Troubleshooting Steps Taken:
Verified Selection: I have confirmed I am selecting the Entity itself in the left-hand list, not an individual Attribute. Ruled out Spotlight Indexing: I understand the difference between database indexing (for internal query performance) and the "Index in Spotlight" checkbox/Core Spotlight framework (for system search). I specifically need the former. Basic Xcode Troubleshooting: I have tried restarting Xcode, cleaning the build folder (Shift+Command+K), and deleting the project's Derived Data. The "Indexes" section remains missing. Checked File Placement/Target Membership: Confirmed the .xcdatamodeld file is correctly included in the target. Its location in the project navigator doesn't seem relevant. Checked Model Versioning: Ensured the correct model version is set as "Current" in the File Inspector. Ruled out Other Features: Confirmed that Fetch Requests, Fetched Properties, and User Info keys are not the mechanisms for defining database indexes. Confirmed Not Project-Specific: I created a brand new, template-generated iOS App project with "Use Core Data" checked. In this new project, when selecting the default "Item" entity, the "Indexes" section is also missing from the Entity Inspector. This strongly suggests the issue is with my Xcode environment/version itself, not my specific project's setup. Considered Programmatic/Manual: I understand Core Data expects schema definitions (including indexes) declaratively in the model file. While manual XML editing of the contents file works (adding <indexes><index>...</index></indexes> within the <entity> tag), this is not the desired or intended workflow via the standard tools.
My Questions:
What is the correct, current procedure for defining non-unique Core Data database indexes using the Xcode UI in Xcode 16.2? Has the location or method for configuring database indexes changed in this version of Xcode? If so, where is it now? Is the absence of the "Indexes" section in the Entity Inspector a known issue or intentional change for this Xcode version? If the standard UI method is unavailable, what is the officially recommended approach (other than manual XML editing)? I've reviewed the documentation ("Configuring Entities", "Configuring Attributes") and while screenshots show the inspectors, they don't definitively show the "Indexes" section within the Entity Inspector, sometimes focusing on attributes or potentially being cropped.
Any clarification or guidance would be greatly appreciated!