Skip to content

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, and NSUserActivity
  • 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, and IndexedEntity

Core Spotlight ​

  • CSSearchableItem, uniqueIdentifier, domainIdentifier, expiration dates
  • CSSearchableItemAttributeSet: common, document, and message attributes
  • CSSearchableIndex: batch indexing; deletion by identifier, by domain, or all
  • CSIndexExtensionRequestHandler, and CSImportExtension limits on macOS

App Intents Integration ​

  • Items created from an app entity, and entities associated with an existing item
  • appEntityIdentifier on an activity, and on-screen content tagging

Semantic Search (27 releases; not tvOS or watchOS) ​

  • SearchableItemAttribute
  • SpotlightSearchTool: 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.

Resources ​

WWDC: 2015-709, 2025-260, 2026-246

Docs: /corespotlight, /corespotlight/cssearchableitem, /corespotlight/spotlightsearchtool, /foundation/nsuseractivity

Released under the MIT License