---
title: "Nutrient Instant and iOS data protection"
canonical_url: "https://www.nutrient.io/guides/ios/pspdfkit-instant/data-protection/"
md_url: "https://www.nutrient.io/guides/ios/pspdfkit-instant/data-protection.md"
last_updated: "2026-05-30T02:20:01.313Z"
description: "Instant and iOS data protection guide for Nutrient iOS SDK with detailed instructions and code examples."
---

# Nutrient Instant and iOS data protection

Nutrient Instant works with [iOS data protection](https://www.nutrient.io/blog/how-to-use-ios-data-protection/).

If you set a default data protection level using an [entitlement](https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_developer_default-data-protection), Instant will use and adopt this for its content.

To set this up, add the entitlement to your app by navigating to the **Signing & Capabilities** section in Xcode, choose **+ Capability**, and add **Data Protection**.

This will add the following to the `.entitlements` file, and you can set the file protection to an appropriate level here:

```xml

<key>com.apple.developer.default-data-protection</key>
<string>NSFileProtectionComplete</string>

```

Instant stores data in a path provided by the [`dataDirectory`](https://www.nutrient.io/api/ios/documentation/instant/instantclient/datadirectory) class property on [`InstantClient`](https://www.nutrient.io/api/ios/documentation/instant/instantclient). However, setting the protection level on the directory to make the containing files inherit the protection level isn’t supported by Instant.

If you’re setting up the entitlement or upgrading the protection type on an existing installation in an app where Instant has already run, use a directory enumerator to change the protection level of already existing content. Decide on an appropriate way to handle errors rather than just logging them:

### SWIFT

```swift

guard let directoryEnumerator = FileManager.default.enumerator(at: InstantClient.dataDirectory, includingPropertiesForKeys: [], options: [], errorHandler: { url, error -> Bool in
    print(error)
    return true
}) else {
    print("Could not create enumerator for Instant data directory.")
    return false
}

// `NSEnumerator` is not generic in Swift so we have to deal with `Any`.
while let file = directoryEnumerator.nextObject() as? NSURL {
    try file.setResourceValue(URLFileProtection.complete, forKey:.fileProtectionKey)
}

```

### OBJECTIVE-C

```objc

NSDirectoryEnumerator<NSURL *> *enumerator = [NSFileManager.defaultManager enumeratorAtURL:PSPDFInstantClient.dataDirectory includingPropertiesForKeys:@[] options:0 errorHandler:^BOOL(NSURL *url, NSError *error) {
    NSLog(@"%@", error);
    return YES;
}];

if (enumerator == nil) {
    NSLog(@"Could not create enumerator for Instant data directory.");
}

for (NSURL *url in enumerator) {
    NSError *error;

    if (![url setResourceValue:NSURLFileProtectionComplete forKey:NSURLFileProtectionKey error:&error]) {
        NSLog(@"%@", error);
    }
}

```

There’s a file called `metadata-shm` in [`dataDirectory`](https://www.nutrient.io/api/ios/documentation/instant/instantclient/datadirectory), and it’s needed for the server metadata database Instant manages. This file always uses the default file protection level `.completeUntilFirstUserAuthentication` to function. However, it doesn’t contain any persistent content, and it’s only used to provide information for multiple processes using the database. For more information on SQLite helper files, see the [official documentation](https://sqlite.org/walformat.html#the_wal_index_or_shm_file).
---

## Related pages

- [Adding comments to PDFs on iOS](/guides/ios/comments/introduction-to-instant-comments.md)
- [Streamline PDF annotation syncing on iOS](/guides/ios/pspdfkit-instant/syncing.md)
- [Nutrient Instant and the document state](/guides/ios/pspdfkit-instant/instant-document-state.md)
- [Frequently asked questions](/guides/ios/instant-synchronization/faq.md)
- [Client authentication in Nutrient Instant](/guides/ios/instant-synchronization/authentication.md)
- [PDF collaboration library for iOS](/guides/ios/instant-synchronization.md)
- [Integrating real-time collaboration into your iOS application](/guides/ios/pspdfkit-instant/getting-started.md)
- [Seamless offline PDF annotation and synchronization](/guides/ios/pspdfkit-instant/offline-support.md)
- [Create PDF annotation layers on iOS](/guides/ios/pspdfkit-instant/instant-layers.md)
- [Nutrient Instant usage](/guides/ios/pspdfkit-instant/usage.md)

