Core Spotlight and NSUserActivity Reference
A lookup reference for making app content searchable with Core Spotlight, and for marking what someone is doing with NSUserActivity. Core Spotlight indexes all your content; NSUserActivity describes the current screen for search, Siri predictions, and Handoff.
When to Use This Reference
Use this reference when you're:
- Indexing documents, notes, orders, or messages for Spotlight
- Choosing between
CSSearchableItem,IndexedEntity, andNSUserActivity - Giving an on-device language model search over your index
- Adding Handoff, Siri predictions, or Quick Note links
- Opening the right screen when someone taps a Spotlight result
- Batching, updating, expiring, or deleting indexed content
- Exposing a custom file type to Spotlight on the Mac
- Debugging content that doesn't appear in Spotlight
Example Prompts
Questions you can ask your assistant that will draw from this reference:
- "How do I index my app's notes in Spotlight?"
- "Should I use NSUserActivity or CSSearchableItem?"
- "How do I index thousands of items efficiently?"
- "How do I open the right order when someone taps a Spotlight result?"
- "Why did my indexed items disappear after a month?"
- "How do I remove everything from the index when someone signs out?"
- "How do I let a LanguageModelSession search my app's content?"
- "Why does my Spotlight import extension do nothing on macOS?"
What's Covered
Choosing an API
- Use cases for
NSUserActivity,CSSearchableItem, andIndexedEntity
Core Spotlight
CSSearchableItem,uniqueIdentifier,domainIdentifier, expiration datesCSSearchableItemAttributeSet: common, document, and message attributesCSSearchableIndex: batch indexing; deletion by identifier, by domain, or allCSIndexExtensionRequestHandler, andCSImportExtensionlimits on macOS
App Intents Integration
- Items created from an app entity, and entities associated with an existing item
appEntityIdentifieron an activity, and on-screen content tagging
Semantic Search (27 releases; not tvOS or watchOS)
SearchableItemAttributeSpotlightSearchTool: sources, index delegate, streaming results, guidance profiles,ContactResolver, pipeline stages, evaluation
Protection Classes (27 releases)
protectionClass,CSSearchableIndexDescription,searchableItems(forIdentifiers:protectionClass:)
NSUserActivity
- Eligibility properties,
becomeCurrent(),resignCurrent(), Quick Note - Continuation in UIKit and SwiftUI, searchable item continuation, deleting saved activities
Testing and Best Practices
- Checking the index, console logs, and common issues
- Selective indexing, domain identifiers, rich metadata, and missing content
- A complete example
Documentation Scope
This page documents the core-spotlight-ref skill (in the axiom-integration suite). The skill has the code and property lists behind each name here.
- For
IndexedEntityand the rest of App Intents, see app-intents-ref
Related
- app-discoverability – Where Spotlight fits in an overall discoverability plan
- app-shortcuts-ref – Making actions, rather than content, available at once
- foundation-models-ref – The sessions and tools that
SpotlightSearchToolplugs into
Resources
WWDC: 2015-709, 2025-260, 2026-246
Docs: /corespotlight, /corespotlight/cssearchableitem, /corespotlight/spotlightsearchtool, /foundation/nsuseractivity