# Apple Privacy Manifest

## Troubleshoot and resolve common issues with the Apple Privacy Manifest and Sentry React Native SDK.

This guide requires [@sentry/react-native@5.22.1](https://github.com/getsentry/sentry-react-native/releases/tag/5.22.1) or newer.

Sentry's SDKs provide error and performance monitoring for mobile applications running on Apple devices. To do this, the SDK needs to access certain information about the device and the application. Some of the APIs required for this are considered privacy-relevant by Apple. In order to submit apps to the App Store, Apple requires all apps - and libraries used within these apps - to provide privacy manifest files stating which APIs are used under which allowed reasons. For more details, read Apple's guidelines on [Describing use of required reason API](https://developer.apple.com/documentation/bundleresources/privacy_manifest_files/describing_use_of_required_reason_api).

The information and steps in this guide are still being worked on and might change because of new tools or updated [Apple requirements](https://developer.apple.com/documentation/bundleresources/privacy_manifest_files).

If you are using dynamically linked frameworks, Apple will automatically process the SDK's privacy manifest. If you are using statically linked libraries, which is the default for React Native applications, you need to provide the privacy manifest yourself. This guide will help you create the privacy manifest for your React Native and Expo applications.

## [Before You Start](#before-you-start)

Note that the application privacy manifest covers all data usages (via `NSPrivacyCollectedDataTypes`) and API usages (via `NSPrivacyAccessedAPITypes`) for the *whole application* and *all included libraries*. The examples below reflect the current requirements for the Sentry SDKs alone. If you are using other libraries that access privacy-relevant APIs, you need to include them in the privacy manifest as well.

## [Create Privacy Manifest in Xcode](#create-privacy-manifest-in-xcode)

First, you need to create a privacy manifest file in your Xcode project. This file should be named `PrivacyInfo.xcprivacy` and should be placed in the root of your Xcode project. Follow the [Privacy manifest files](https://developer.apple.com/documentation/bundleresources/privacy_manifest_files#4284009) guide by Apple to create the file.

`PrivacyInfo.xcprivacy`

```xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
  "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>NSPrivacyCollectedDataTypes</key>
	<array>
		<dict>
			<key>NSPrivacyCollectedDataType</key>
			<string>NSPrivacyCollectedDataTypeCrashData</string>
			<key>NSPrivacyCollectedDataTypeLinked</key>
			<false />
			<key>NSPrivacyCollectedDataTypeTracking</key>
			<false />
			<key>NSPrivacyCollectedDataTypePurposes</key>
			<array>
				<string>NSPrivacyCollectedDataTypePurposeAppFunctionality</string>
			</array>
		</dict>
		<dict>
			<key>NSPrivacyCollectedDataType</key>
			<string>NSPrivacyCollectedDataTypePerformanceData</string>
			<key>NSPrivacyCollectedDataTypeLinked</key>
			<false />
			<key>NSPrivacyCollectedDataTypeTracking</key>
			<false />
			<key>NSPrivacyCollectedDataTypePurposes</key>
			<array>
				<string>NSPrivacyCollectedDataTypePurposeAppFunctionality</string>
			</array>
		</dict>
		<dict>
			<key>NSPrivacyCollectedDataType</key>
			<string>NSPrivacyCollectedDataTypeOtherDiagnosticData</string>
			<key>NSPrivacyCollectedDataTypeLinked</key>
			<false />
			<key>NSPrivacyCollectedDataTypeTracking</key>
			<false />
			<key>NSPrivacyCollectedDataTypePurposes</key>
			<array>
				<string>NSPrivacyCollectedDataTypePurposeAppFunctionality</string>
			</array>
		</dict>
	</array>
	<key>NSPrivacyAccessedAPITypes</key>
	<array>
		<dict>
			<key>NSPrivacyAccessedAPIType</key>
			<string>NSPrivacyAccessedAPICategoryUserDefaults</string>
			<key>NSPrivacyAccessedAPITypeReasons</key>
			<array>
				<string>CA92.1</string>
			</array>
		</dict>
		<dict>
			<key>NSPrivacyAccessedAPIType</key>
			<string>NSPrivacyAccessedAPICategorySystemBootTime</string>
			<key>NSPrivacyAccessedAPITypeReasons</key>
			<array>
				<string>35F9.1</string>
			</array>
		</dict>
		<dict>
			<key>NSPrivacyAccessedAPIType</key>
			<string>NSPrivacyAccessedAPICategoryFileTimestamp</string>
			<key>NSPrivacyAccessedAPITypeReasons</key>
			<array>
				<string>C617.1</string>
			</array>
		</dict>
	</array>
</dict>
</plist>
```

## [Create Privacy Manifest in Expo](#create-privacy-manifest-in-expo)

Depending on the Expo application setup, if you're using Continuous Native Generation ([CNG](https://docs.expo.dev/workflow/continuous-native-generation/)), then you may need to add the privacy manifest to the `app.json` file. Otherwise, you can add your privacy manifest using Xcode.

`app.json`

```json
{
  "expo": {
    "name": "My App",
    "slug": "my-app",
    "ios": {
      "privacyManifests": {
        "NSPrivacyCollectedDataTypes": [
          {
            "NSPrivacyCollectedDataType": "NSPrivacyCollectedDataTypeCrashData",
            "NSPrivacyCollectedDataTypeLinked": false,
            "NSPrivacyCollectedDataTypeTracking": false,
            "NSPrivacyCollectedDataTypePurposes": [
              "NSPrivacyCollectedDataTypePurposeAppFunctionality"
            ]
          },
          {
            "NSPrivacyCollectedDataType": "NSPrivacyCollectedDataTypePerformanceData",
            "NSPrivacyCollectedDataTypeLinked": false,
            "NSPrivacyCollectedDataTypeTracking": false,
            "NSPrivacyCollectedDataTypePurposes": [
              "NSPrivacyCollectedDataTypePurposeAppFunctionality"
            ]
          },
          {
            "NSPrivacyCollectedDataType": "NSPrivacyCollectedDataTypeOtherDiagnosticData",
            "NSPrivacyCollectedDataTypeLinked": false,
            "NSPrivacyCollectedDataTypeTracking": false,
            "NSPrivacyCollectedDataTypePurposes": [
              "NSPrivacyCollectedDataTypePurposeAppFunctionality"
            ]
          }
        ],
        "NSPrivacyAccessedAPITypes": [
          {
            "NSPrivacyAccessedAPIType": "NSPrivacyAccessedAPICategoryUserDefaults",
            "NSPrivacyAccessedAPITypeReasons": ["CA92.1"]
          },
          {
            "NSPrivacyAccessedAPIType": "NSPrivacyAccessedAPICategorySystemBootTime",
            "NSPrivacyAccessedAPITypeReasons": ["35F9.1"]
          },
          {
            "NSPrivacyAccessedAPIType": "NSPrivacyAccessedAPICategoryFileTimestamp",
            "NSPrivacyAccessedAPITypeReasons": ["C617.1"]
          }
        ]
      }
    }
  }
}
```

## [Troubleshooting](#troubleshooting)

* For more information about generating the privacy manifest using Expo, read the [Privacy manifests](https://docs.expo.dev/guides/apple-privacy/) guide by Expo.

* The listed APIs are required for the SDK to function correctly and there is no way to opt-out of them.

* If you are using an older version of the SDK, you may need to update to version [5.22.1](https://github.com/getsentry/sentry-react-native/releases/tag/5.22.1) or later to automatically include the privacy manifest for dynamically linked frameworks.

* To verify the privacy manifest is included in your app correctly, build and submit your app to the App Store or TestFlight for external testing. If the manifest is missing, you will receive an email from Apple with the subject, "The uploaded build for YourAppName has one or more issues", that lists the missing API declarations.
