---
title: "Index & Search PDFs in iOS Viewer | Nutrient SDK"
canonical_url: "https://www.nutrient.io/guides/ios/search/indexed-full-text-search/spotlight-indexing/"
md_url: "https://www.nutrient.io/guides/ios/search/indexed-full-text-search/spotlight-indexing.md"
last_updated: "2026-05-30T02:20:01.333Z"
description: "PSPDFKit's PDFLibrary implements a full-text-search engine based on a SQLite database that can also optionally index documents with Spotlight."
---

# Index and Search PDFs Using iOS Spotlight

PSPDFKit's [`PDFLibrary`](https://www.nutrient.io/api/ios/documentation/pspdfkit/pdflibrary) implements a full-text-search engine based on a SQLite database that can also optionally index documents with Spotlight, so the user can search for documents (and their text) from the native device search. To enable this, [set up `PDFLibrary`](https://www.nutrient.io/guides/ios/features/indexed-full-text-search/), and set the [`spotlightIndexingType`](https://www.nutrient.io/api/ios/documentation/pspdfkit/pdflibrary/spotlightindexingtype-swift.property) property before calling [`PDFLibrary.updateIndex(completionHandler:)`](https://www.nutrient.io/api/ios/documentation/pspdfkit/pdflibrary/updateindex(completionhandler:)). This can be set to one of the following:

- [`.disabled`](https://www.nutrient.io/api/ios/documentation/pspdfkit/pdflibrary/spotlightindexingtype-swift.enum/disabled) — documents are not indexed in Spotlight

- [`.enabled`](https://www.nutrient.io/api/ios/documentation/pspdfkit/pdflibrary/spotlightindexingtype-swift.enum/enabled) — documents are indexed in Spotlight, but their text is not

- [`.enabledWithFullText`](https://www.nutrient.io/api/ios/documentation/pspdfkit/pdflibrary/spotlightindexingtype-swift.enum/enabledwithfulltext) — documents are indexed in Spotlight with their full text

## Retrieving Documents from Spotlight

When the user taps on a searchable item from your app in Spotlight search results, your app delegate’s `application(_:continue:restorationHandler:)` method is called.
In your implementation of this method, call [`PDFLibrary.fetchSpotlightIndexedDocument(for:completionHandler:)`](https://www.nutrient.io/api/ios/documentation/pspdfkit/pdflibrary/fetchspotlightindexeddocument(for:completionhandler:)) to retrieve the document, if any:

### SWIFT

```swift

func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
    guard let library = PSPDFKit.SDK.shared.library else {
        logError("Unable to get shared PDFLibrary instance to continue user activity.")
        return false
    }
    library.fetchSpotlightIndexedDocument(for: userActivity) {
        guard let document = $0 else { return }
        // Open the document in a `PDFViewController`.
    }

    return true
}

```

### OBJECTIVE-C

```objc

- (BOOL)application:(NSApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray *restorableObjects))restorationHandler {
    PSPDFLibrary *library = PSPDFKitGlobal.sharedInstance.library;
    if (!library) {
        // FTS feature isn't enabled in your license.
        return NO;
    }
    [PSPDFKitGlobal.sharedInstance.library fetchSpotlightIndexedDocumentForUserActivity:userActivity completionHandler:^(PSPDFDocument *document) {
        if (!document) {
            return;
        }
        // Open the document in a `PSPDFViewController`.
    }];
    return YES;
}

```
---

## Related pages

- [Generate PDF Search Previews on iOS](/guides/ios/search/indexed-full-text-search/customize-results.md)
- [Adding a Custom SQLite Library for PDF Search on iOS](/guides/ios/miscellaneous/custom-sqlite-library.md)
- [PDF Search Matching Options on iOS](/guides/ios/search/indexed-full-text-search/matching-options.md)
- [Custom Tokenizers for PDF Search on iOS](/guides/ios/memory-and-storage/using-custom-tokenizers.md)
- [Indexing PDF Documents on iOS](/guides/ios/features/indexed-full-text-search.md)
- [Encrypt the PDF Search Database on iOS](/guides/ios/security/encryption-in-pdflibrary.md)

