<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -",
    "macOS: 27.0.0 -",
    "visionOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreSpotlight",
  "identifier" : "/documentation/CoreSpotlight/CoreSpotlightSource",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Core Spotlight",
      "FoundationModels"
    ],
    "preciseIdentifier" : "s:31_CoreSpotlight_FoundationModels0aB6SourceV"
  },
  "title" : "CoreSpotlightSource"
}
-->

# CoreSpotlightSource

A search source that retrieves data from the app’s Spotlight index.

```
struct CoreSpotlightSource
```

## Overview

Use this type to configure the Spotlight search tool to search your app’s indexed content. When
performing searches, the tool queries your content for [`CSSearchableItem`](/documentation/CoreSpotlight/CSSearchableItem) objects that match
the specified criteria. When delivering search results to the model, the tool delivers each item’s
identifier and any attributes you specify in the [`fetchAttributes`](/documentation/CoreSpotlight/CoreSpotlightSource/fetchAttributes) property. To provide
additional item-specific content that isn’t in the Spotlight index, provide a delegate object
to generate that data dynamically from your content.

This type is `@unchecked Sendable` because [`CSSearchableIndexDelegate`](/documentation/CoreSpotlight/CSSearchableIndexDelegate) is a non-Sendable ObjC protocol.
If you provide a delegate object, you must ensure that object is safe to use across isolation boundaries.

## Topics

### Creating a Spotlight source

[`init(fetchAttributes: [SearchableItemAttribute])`](/documentation/CoreSpotlight/CoreSpotlightSource/init(fetchAttributes:))

[`init(searchableIndexDelegate: (any CSSearchableIndexDelegate)?, fetchAttributes: [SearchableItemAttribute])`](/documentation/CoreSpotlight/CoreSpotlightSource/init(searchableIndexDelegate:fetchAttributes:))

### Configuring the search options

[`var fetchAttributes: [SearchableItemAttribute]`](/documentation/CoreSpotlight/CoreSpotlightSource/fetchAttributes)

The attributes to fetch for each item and provide to the model.

[`var sourceOptions: CSSearchQueryContext.SourceOptions`](/documentation/CoreSpotlight/CoreSpotlightSource/sourceOptions)

Options you use to specify access to restricted content.

[`var maximumResultCount: Int?`](/documentation/CoreSpotlight/CoreSpotlightSource/maximumResultCount)

The maximum number of results to retrieve from this source.

### Providing additional attributes

[`var searchableIndexDelegate: (any CSSearchableIndexDelegate)?`](/documentation/CoreSpotlight/CoreSpotlightSource/searchableIndexDelegate)

An optional delegate object you use to provide additional data about items in search results.

[`protocol CSSearchableIndexDelegate`](/documentation/CoreSpotlight/CSSearchableIndexDelegate)

A protocol that defines methods a delegate object or app extension uses to handle communication from the on-device index.

## Relationships

### Conforms To

[`Sendable`](/documentation/Swift/Sendable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)