Skip to content
2 changes: 1 addition & 1 deletion contents/docs/error-tracking/installation/react-native.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ import { ErrorTrackingReactNativeInstallationWrapper } from './_snippets/et-inst

## iOS dependency resolution for native crash capture

The `@posthog/react-native-plugin` package supports CocoaPods, the hybrid CocoaPods and Swift Package Manager path, and React Native's full Swift Package Manager integration. PostHog verifies the full path with an iOS-only React Native 0.87.1 app and React Native Community CLI 20.2.0. This path requires `@posthog/react-native-plugin` 2.4.0 or later, Xcode 16 or later, and an iOS 15.1 or later app deployment target.
The `@posthog/react-native-plugin` package supports CocoaPods, the hybrid CocoaPods and Swift Package Manager path, and React Native's full Swift Package Manager integration. PostHog verifies the full path with an iOS-only React Native 0.87.1 app and React Native Community CLI 20.2.0. This path requires `@posthog/react-native-plugin` 2.4.0 or later, Xcode 16 or later, and an iOS 15.1 or later app deployment target. `@posthog/react-native-plugin` 3.0 and later requires React Native 0.75 or later and, on every path, Xcode 26 or later and an iOS 15 or later deployment target. From 3.0, the CocoaPods path resolves `posthog-ios` through Swift Package Manager, so the separate hybrid path applies to 2.x only.

See [iOS dependency paths for the React Native native plugin](/docs/libraries/react-native#choose-an-ios-dependency-path-for-the-native-plugin) for the requirements and setup steps. This verification does not cover Expo or other React Native versions. Use CocoaPods or the hybrid path unless you validate full Swift Package Manager for your configuration.
Original file line number Diff line number Diff line change
Expand Up @@ -298,11 +298,11 @@ In Xcode, add a **Run Script** build phase to your main app target and place it

<MultiLanguage>

```bash file=CocoaPods
```bash file=CocoaPods (plugin 2.x)
"${PODS_ROOT}/PostHog/build-tools/upload-symbols.sh"
```

```bash file=Swift Package Manager
```bash file=Swift Package Manager (and plugin 3.0 and later)
"${BUILD_DIR%/Build/*}/SourcePackages/checkouts/posthog-ios/build-tools/upload-symbols.sh"
```

Expand All @@ -317,11 +317,11 @@ To also upload native source files for source-code context (iOS only), prefix th

<MultiLanguage>

```bash file=CocoaPods
```bash file=CocoaPods (plugin 2.x)
POSTHOG_INCLUDE_SOURCE=1 "${PODS_ROOT}/PostHog/build-tools/upload-symbols.sh"
```

```bash file=Swift Package Manager
```bash file=Swift Package Manager (and plugin 3.0 and later)
POSTHOG_INCLUDE_SOURCE=1 "${BUILD_DIR%/Build/*}/SourcePackages/checkouts/posthog-ios/build-tools/upload-symbols.sh"
```

Expand Down
58 changes: 52 additions & 6 deletions contents/docs/libraries/react-native/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,17 @@ import ReactNativeInstall from '../../integrate/_snippets/install-react-native.m

### Choose an iOS dependency path for the native plugin

The optional `@posthog/react-native-plugin` package adds native features such as session replay and native crash capture. Install it as described in the guide for the feature that you use. Then choose one iOS dependency path:
The optional `@posthog/react-native-plugin` package adds native features such as session replay and native crash capture. Install it as described in the guide for the feature that you use.

`@posthog/react-native-plugin` 3.0 and later requires React Native 0.75 or later and, on every iOS dependency path, Xcode 26 or later and an iOS 15 or later deployment target (macOS 11 or later for React Native macOS apps). See [Upgrading to `@posthog/react-native-plugin` 3.0](#upgrading-to-posthogreact-native-plugin-30).

Then choose one iOS dependency path:

| Path | Requirements | What it resolves |
| --- | --- | --- |
| CocoaPods | A React Native project that uses CocoaPods | CocoaPods resolves the plugin and `posthog-ios`. This remains the default path. |
| CocoaPods with `posthog-ios` through Swift Package Manager | React Native 0.75 or later and a CocoaPods project with dynamic frameworks | CocoaPods resolves the plugin. Swift Package Manager resolves `posthog-ios`. |
| Full Swift Package Manager | Verified with an iOS-only React Native 0.87.1 app and React Native Community CLI 20.2.0.<br/><br/>Requires `@posthog/react-native-plugin` 2.4.0 or later, Xcode 16 or later, and an iOS 15.1 or later app deployment target. | React Native's experimental Swift Package Manager integration resolves the plugin and `posthog-ios`. This path does not use CocoaPods. |
| CocoaPods | A React Native project that uses CocoaPods | CocoaPods resolves the plugin. From `@posthog/react-native-plugin` 3.0, Swift Package Manager resolves `posthog-ios`. In earlier versions, CocoaPods resolves it. This remains the default path. |
| CocoaPods with `posthog-ios` through Swift Package Manager | `@posthog/react-native-plugin` 2.x only. React Native 0.75 or later and a CocoaPods project with dynamic frameworks | CocoaPods resolves the plugin. Swift Package Manager resolves `posthog-ios`. From 3.0, the CocoaPods path does this by default. |
| Full Swift Package Manager | Verified with an iOS-only React Native 0.87.1 app and React Native Community CLI 20.2.0.<br/><br/>Requires `@posthog/react-native-plugin` 2.4.0 or later, Xcode 16 or later (Xcode 26 or later for plugin 3.0 and later), and an iOS 15.1 or later app deployment target. | React Native's experimental Swift Package Manager integration resolves the plugin and `posthog-ios`. This path does not use CocoaPods. |

This verification does not cover Expo or other React Native versions. Use CocoaPods or the hybrid path unless you validate the full Swift Package Manager path for your configuration.

Expand All @@ -49,10 +53,12 @@ cd ios
pod install
```

The plugin podspec adds `posthog-ios` as a CocoaPods dependency. You do not need to add `posthog-ios` separately.
The plugin podspec adds `posthog-ios` for you. You do not need to add `posthog-ios` separately. From `@posthog/react-native-plugin` 3.0, the podspec adds it through Swift Package Manager with React Native's `spm_dependency` helper. Static libraries, static frameworks and dynamic frameworks all work. Earlier versions add it as a CocoaPods dependency.

#### CocoaPods with `posthog-ios` through Swift Package Manager

This path applies to `@posthog/react-native-plugin` 2.x only. From 3.0, the CocoaPods path already resolves `posthog-ios` through Swift Package Manager and the plugin ignores `posthog.useSpm`.

Add the following property to `ios/Podfile.properties.json`:

```json
Expand Down Expand Up @@ -88,7 +94,7 @@ npx react-native spm add --deintegrate --yes

The `--deintegrate` option removes the complete CocoaPods integration from the iOS project. React Native then finds the plugin's `ios/Package.swift` manifest. Swift Package Manager resolves the plugin and `posthog-ios`. Do not run `pod install` for this path.

PostHog CI verifies this path with the configuration in the requirements table. The verified app sets its deployment target to iOS 15.1. The plugin package manifest has a separate iOS 15 minimum. The CocoaPods and hybrid paths keep the plugin podspec's iOS 13 minimum.
PostHog CI verifies this path with the configuration in the requirements table. The verified app sets its deployment target to iOS 15.1. The plugin package manifest has a separate iOS 15 minimum. On the CocoaPods and hybrid paths, the plugin podspec's minimum is iOS 15 from `@posthog/react-native-plugin` 3.0, and iOS 13 in earlier versions.

<DetailSetUpReverseProxy />

Expand Down Expand Up @@ -693,6 +699,46 @@ const MyComponent = () => {
}
```

## Upgrading to `@posthog/react-native-plugin` 3.0

`@posthog/react-native-plugin` 3.0 uses `posthog-ios` 4.0. For before-and-after examples and a checklist, see the [migration guide](https://github.com/PostHog/posthog-js/blob/main/packages/react-native-plugin/MIGRATION.md). The plugin requires:

- React Native 0.75 or later

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 · Document React Native 0.71 as the plugin minimum

For apps on React Native 0.71–0.74, this requirement incorrectly rules out plugin 3.0 and directs users toward an unnecessary framework upgrade. The upstream plugin's package.json declares react-native: >=0.71; 0.75 is the requirement for the optional spm_dependency integration. Use 0.71 for the plugin minimum across all three pages.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not changing: posthog-js #5449 raises the plugin peerDependency to react-native: >=0.75 and the podspec raises an error below 0.75, since spm_dependency is now mandatory.

- Xcode 26 or later, on every iOS dependency path
- An iOS 15 or later deployment target, and macOS 11 or later for React Native macOS apps

On iOS, the plugin now always resolves `posthog-ios` through Swift Package Manager:

- Remove `"posthog.useSpm"` from `ios/Podfile.properties.json` if you set it. The plugin no longer reads it.
- The plugin no longer needs `use_frameworks! :linkage => :dynamic`. Keep it only if another dependency needs it.
Comment on lines +710 to +713

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 · Preserve the opt-in Swift Package Manager configuration

For apps using the hybrid path, removing posthog.useSpm switches dependency resolution back to CocoaPods. The plugin podspec still reads this property and defaults to s.dependency 'PostHog'; the referenced 4.0 update only changes its version pin. Removing dynamic frameworks also violates the hybrid path's requirements. Retain both settings and correct the path descriptions.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not changing: posthog-js #5449 drops posthog.useSpm from the podspec and always calls spm_dependency (CI now covers static libraries and dynamic frameworks), so 3.0 no longer reads the property or needs dynamic frameworks.

- Remove the legacy `posthog-react-native-session-replay` package if your app still depends on it. It pulls in `posthog-ios` 3.x, and the plugin uses 4.x.
- Remove these Podfile settings if you use them, because `pod install` now fails with them: `:generate_multiple_pod_projects => true`, `:deduplicate_targets => false`, and targets that use the plugin with different `platform` or `use_frameworks!` settings.
- Make sure build machines can reach `https://github.com/PostHog/posthog-ios.git`, because Xcode now fetches `posthog-ios` from there.
- If your app target has `import PostHog`, check that it still compiles. React Native's helper adds the package only to the plugin's pod target. This case isn't tested, but if the import no longer resolves, add `posthog-ios` to your app target as a Swift package with a compatible version.
- If a custom dSYM upload script calls `${PODS_ROOT}/PostHog/build-tools/upload-symbols.sh`, change it to `${BUILD_DIR%/Build/*}/SourcePackages/checkouts/posthog-ios/build-tools/upload-symbols.sh`. The `uploadNativeSymbols` build phase from the Expo config plugin already checks both paths.

Apps that use the plugin only through `posthog-react-native` need no code changes. If your code calls the plugin directly:

- Call `setup()` instead of the removed `start()` method. `setup()` takes three arguments and reads the replay settings from `pluginConfig.sessionReplay`. Replay starts only when `sessionReplay.enabled` is `true`, which defaults to `false`:

```ts
// Before
start(sessionId, sdkOptions, sdkReplayConfig, decideReplayConfig)

// After
setup(sessionId, sdkOptions, {
sessionReplay: { enabled: true, sdkReplayConfig, decideReplayConfig },
})
```

- Pass `throttleDelayMs` instead of `iOSdebouncerDelayMs` or `androidDebouncerDelayMs`, which the plugin no longer reads. `posthog-react-native` still maps these deprecated options to `throttleDelayMs`.

On iOS, native uploads (session replay and native crash reports) pause while cellular data is turned off for your app, instead of sending requests that fail.

The experimental iOS session replay option `sessionReplayConfig.screenshotModeBackgroundCapture` no longer has an effect, because `posthog-ios` 4.0 removes it.

Session replay records only masked screenshots on iOS and Android, because `posthog-ios` 4.0 and `posthog-android` 4.0 remove wireframe capture. The plugin already forced screenshot mode, so your recordings don't change. If native code in your app sets `screenshotMode` (iOS) or `screenshot` (Android), remove it, because it no longer compiles.

## Upgrading from V1, V2 to V3 or V3 to V4

V1 of this library utilised the underlying `posthog-ios` and `posthog-android` SDKs to do most of the work. Since the new version is written entirely in JS, using only Expo supported libraries, there are some changes to the way PostHog is configured as well as actually calling PostHog.
Expand Down
10 changes: 6 additions & 4 deletions contents/docs/session-replay/installation/react-native.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@ import { SRReactNativeInstallationWrapper } from './_snippets/sr-installation-wr

## iOS dependency resolution

The native plugin supports three additive iOS dependency paths:
The native plugin supports these iOS dependency paths:

- CocoaPods for the plugin and `posthog-ios`. This remains the default path.
- CocoaPods for the plugin, with `posthog-ios` resolved through Swift Package Manager.
- CocoaPods for the plugin. This remains the default path. From `@posthog/react-native-plugin` 3.0, Swift Package Manager resolves `posthog-ios`. In earlier versions, CocoaPods resolves it.
- In `@posthog/react-native-plugin` 2.x only, CocoaPods for the plugin with `posthog-ios` resolved through Swift Package Manager, using the `posthog.useSpm` property.
- React Native's experimental full Swift Package Manager integration, with no CocoaPods. PostHog verifies an iOS-only React Native 0.87.1 app with React Native Community CLI 20.2.0. This path requires `@posthog/react-native-plugin` 2.4.0 or later, Xcode 16 or later, and an iOS 15.1 or later app deployment target.

`@posthog/react-native-plugin` 3.0 and later requires React Native 0.75 or later and, on every path, Xcode 26 or later and an iOS 15 or later deployment target.

See [iOS dependency paths for the React Native native plugin](/docs/libraries/react-native#choose-an-ios-dependency-path-for-the-native-plugin) for the requirements and setup steps. This verification does not cover Expo or other React Native versions. Use CocoaPods or the hybrid path unless you validate full Swift Package Manager for your configuration.

## Troubleshooting

- If session replay looks janky or drops frames on high-refresh-rate (120Hz ProMotion) iPhones, turn on the experimental `sessionReplayConfig.screenshotModeBackgroundCapture` option (iOS only, requires `posthog-react-native` 4.45.0 or higher) to move screenshot capture off the main thread. This can trigger Xcode's Main Thread Checker warnings, so disable it in your scheme's Run diagnostics if that happens.
- If session replay looks janky or drops frames on high-refresh-rate (120Hz ProMotion) iPhones, turn on the experimental `sessionReplayConfig.screenshotModeBackgroundCapture` option (iOS only, requires `posthog-react-native` 4.45.0 or higher and `@posthog/react-native-plugin` 2.x) to move screenshot capture off the main thread. This can trigger Xcode's Main Thread Checker warnings, so disable it in your scheme's Run diagnostics if that happens.
Loading