<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreSpotlight",
  "identifier" : "/documentation/CoreSpotlight/CSImportExtension",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Core Spotlight"
    ],
    "preciseIdentifier" : "c:objc(cs)CSImportExtension"
  },
  "title" : "CSImportExtension"
}
-->

# CSImportExtension

An object that provides searchable attributes for file types that the app supports.

```
class CSImportExtension
```

## Overview

To create a Spotlight File Import extension, add a target to your app using the Spotlight File Import extension template in Xcode. The template project contains a subclass of `CSImportExtension`. To index content on a user’s device, Core Spotlight loads your extension and invokes the [`update(_:forFileAt:)`](/documentation/CoreSpotlight/CSImportExtension/update(_:forFileAt:)) method. Core Spotlight passes a [`CSSearchableItemAttributeSet`](/documentation/CoreSpotlight/CSSearchableItemAttributeSet) and URL of a file to the extension, and you set properties that are relevant for the file.

> Important: Spotlight File Import extensions don’t provide functionality in macOS. To make custom files available to Spotlight in macOS, create a Spotlight importer plugin. For more information, refer to [Spotlight Importer Programming Guide](https://developer.apple.com/library/archive/documentation/Carbon/Conceptual/MDImporters/MDImporters.html#//apple_ref/doc/uid/TP40001267).

Typically, your extension loads details about the file and uses that information to set properties of the attribute set. For example, if your app contains files that are notes the user creates, it does the following:

```swift
class NoteImporter: CSImportExtension {
    override func update(_ attributes: CSSearchableItemAttributeSet, forFileAt contentURL: URL) throws {
        // NoteDetails is an app-defined object that encapsulates a note.
        guard let note = NoteDetails.noteDetails(for: contentURL) else {
            throw NoteError.noteNotFound
        }
        attributes.title = note.title
        attributes.contentCreationDate = note.creationDate
        attributes.userCreated = NSNumber(booleanLiteral: true)
    }
}
```

> Important:
> Core Spotlight indexes files in batches and may call ``doc://com.apple.corespotlight/documentation/CoreSpotlight/CSImportExtension/update(_:forFileAt:)`` simultaneously on multiple queues with different values of `contentURL`.

To specify the file types your app supports, set the value of <doc://com.apple.documentation/documentation/BundleResources/Information-Property-List/NSExtension/NSExtensionAttributes/CSSupportedContentTypes> in your extension’s `Info.plist` file to an array of file type identifiers. For more information about file type identifiers, see <doc://com.apple.documentation/documentation/UniformTypeIdentifiers>. The app in the previous example configures the extension’s `Info.plist` as follows:

```swift
<key>NSExtension</key>
<dict>
    <key>NSExtensionPointIdentifier</key>
    <string>com.apple.spotlight.import</string>
    <key>NSExtensionPrincipalClass</key>
    <string>FileImporter</string>
    <key>NSExtensionAttributes</key>
    <dict>
        <key>CSSupportedContentTypes</key>
        <array>
            <string>com.example.mynoteapp.note</string>
        </array>
    </dict>
</dict>
```

## Topics

### Providing searchable attributes

[`update(_:forFileAt:)`](/documentation/CoreSpotlight/CSImportExtension/update(_:forFileAt:))

Provides searchable attributes for a file at the specified URL.



---

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)