# iOS session replay installation - Docs

1.  1

    ## Install the SDK

    Required

    Add PostHog to your Podfile:

    Podfile

    PostHog AI

    ```ruby
    pod "PostHog", "~> 3.0"
    ```

    Or install via Swift Package Manager:

    Package.swift

    PostHog AI

    ```swift
    dependencies: [
      .package(url: "https://github.com/PostHog/posthog-ios.git", from: "3.0.0")
    ]
    ```

    **SDK version**

    Session replay requires PostHog iOS SDK version 3.6.0 or higher. We recommend always using the latest version.

2.  2

    ## Enable session recordings in project settings

    Required

    Go to your PostHog [Project Settings](https://us.posthog.com/settings/project-replay) and enable **Record user sessions**. Session recordings will not work without this setting enabled.

3.  3

    ## Configure PostHog with session replay

    Required

    Add `sessionReplay = true` to your PostHog configuration. Here are all the available options:

    AppDelegate.swift

    PostHog AI

    ```swift
    import Foundation
    import PostHog
    import UIKit
    class AppDelegate: NSObject, UIApplicationDelegate {
        func application(_: UIApplication, didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
            let POSTHOG_TOKEN = "<ph_project_token>"
            let POSTHOG_HOST = "https://us.i.posthog.com"
            let config = PostHogConfig(apiKey: POSTHOG_TOKEN, host: POSTHOG_HOST)
            // Enable session recording. Requires enabling in your project settings as well.
            // Default is false.
            config.sessionReplay = true
            // Whether text and text input fields are masked. Default is true.
            // Password inputs are always masked regardless
            config.sessionReplayConfig.maskAllTextInputs = true
            // Whether images are masked. Default is true.
            config.sessionReplayConfig.maskAllImages = true
            // Whether logs are captured in recordings. Default is false.
            //
            // Support for remote configuration
            // in the [session replay settings](https://app.posthog.com/settings/project-replay#replay-log-capture)
            // requires SDK version 3.41.1 or higher.
            config.sessionReplayConfig.captureLogs = false
            // Whether network requests are captured in recordings. Default is true
            // Only metric-like data like speed, size, and response code are captured.
            // No data is captured from the request or response body.
            //
            // Support for remote configuration
            // in the [session replay settings](https://app.posthog.com/settings/project-replay#replay-network)
            // requires SDK version 3.41.1 or higher.
            config.sessionReplayConfig.captureNetworkTelemetry = true
            // Whether replays are created using high quality screenshots. Default is false.
            // Required for SwiftUI.
            // If disabled, replays are created using wireframes instead.
            // The screenshot may contain sensitive information, so use with caution
            config.sessionReplayConfig.screenshotMode = true
            // Sample rate for session recordings. A value between 0.0 and 1.0.
            // 1.0 means 100% of sessions will be recorded. 0.5 means 50%, and so on.
            // Default is nil (all sessions are recorded).
            //
            // Support for remote configuration
            // in the [session replay triggers](https://us.posthog.com/settings/project-replay#replay-triggers)
            // requires SDK version 3.42.0 or higher.
            config.sessionReplayConfig.sampleRate = nil
            PostHogSDK.shared.setup(config)
            return true
        }
    }
    ```

    For more configuration options, see the [iOS session replay docs](/docs/session-replay/installation?tab=iOS.md).

    **SwiftUI support**

    SwiftUI is only supported if the `screenshotMode` option is enabled. Custom views and WebViews also require screenshot mode for full support.

4.  4

    ## Watch session recordings

    Recommended

    Visit your site or app and interact with it for at least 10 seconds to generate a recording. Navigate between pages, click buttons, and fill out forms to capture meaningful interactions.

    [Watch your first recording →](/replay/home.md)

5.  5

    ## Next steps

    Recommended

    Now that you're recording sessions, continue with the resources below to learn what else Session Replay enables within the PostHog platform.

    | Resource | Description |
    | --- | --- |
    | [Watching recordings](/docs/session-replay/how-to-watch-recordings.md) | How to find and watch session recordings |
    | [Privacy controls](/docs/session-replay/privacy.md) | How to mask sensitive data in recordings |
    | [Network recording](/docs/session-replay/network-recording.md) | How to capture network requests in recordings |
    | [Console log recording](/docs/session-replay/console-log-recording.md) | How to capture console logs in recordings |
    | [More tutorials](/docs/session-replay/tutorials.md) | Other real-world examples and use cases |

### Community questions

Ask a question

### Was this page useful?

HelpfulCould be better