<!--
{
  "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/FileSource",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Core Spotlight",
      "FoundationModels"
    ],
    "preciseIdentifier" : "s:31_CoreSpotlight_FoundationModels10FileSourceV"
  },
  "title" : "FileSource"
}
-->

# FileSource

A search source that retrieves indexed metadata from files and directories visible to Spotlight.

```
struct FileSource
```

## Overview

Use this type to search the metadata of your app’s custom file types. Configure the source with one
or more directories for the tool to search. During a query, the Spotlight considers only the previously
indexed files in those directories. When it finds a match, the tool delivers the item and any attributes
you specify in the [`fetchAttributes`](/documentation/CoreSpotlight/FileSource/fetchAttributes) property to the model for consideration.

For more information about indexing your app’s files, see [`CSImportExtension`](/documentation/CoreSpotlight/CSImportExtension).

## Topics

### Creating a file source

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

### Configuring the search options

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

The attributes to fetch for each file or directory and provide to the model.

[`var scopes: [URL]`](/documentation/CoreSpotlight/FileSource/scopes)

The directories to search.

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

The maximum number of results to retrieve from this source.

## Relationships

### Conforms To

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

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

---

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)