> ## Documentation Index
> Fetch the complete documentation index at: https://sentrydocs.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Mobile SDKs

> Instrument iOS, Android, and React Native applications with Sentry

Sentry provides dedicated SDKs for each major mobile platform. All three support automatic crash reporting, performance monitoring, and session tracking out of the box.

<CardGroup cols={3}>
  <Card title="iOS" icon="apple">
    Swift and Objective-C apps via `sentry-cocoa`.
  </Card>

  <Card title="Android" icon="android">
    Java and Kotlin apps via `sentry-android`.
  </Card>

  <Card title="React Native" icon="mobile">
    Cross-platform apps via `@sentry/react-native`.
  </Card>
</CardGroup>

## iOS (Swift / Objective-C)

### Installation

<Tabs>
  <Tab title="Swift Package Manager">
    In Xcode, go to **File → Add Package Dependencies** and enter:

    ```
    https://github.com/getsentry/sentry-cocoa
    ```

    Select version `8.0.0` or later. Or add it directly to `Package.swift`:

    ```swift theme={null}
    // Package.swift
    dependencies: [
        .package(
            url: "https://github.com/getsentry/sentry-cocoa",
            from: "8.0.0"
        ),
    ],
    targets: [
        .target(
            name: "YourApp",
            dependencies: ["Sentry"]
        ),
    ]
    ```
  </Tab>

  <Tab title="CocoaPods">
    Add to your `Podfile`:

    ```ruby theme={null}
    pod 'Sentry', '~> 8.0'
    ```

    Then run:

    ```bash theme={null}
    pod install
    ```
  </Tab>
</Tabs>

### Initialization

Initialize Sentry in your `AppDelegate` or the `@main` entry point, before the rest of your app starts:

```swift theme={null}
import Sentry

@main
struct MyApp: App {
    init() {
        SentrySDK.start { options in
            options.dsn = "https://examplePublicKey@o0.ingest.sentry.io/0"
            options.environment = "production"
            options.releaseName = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String
            options.debug = false
            options.tracesSampleRate = 1.0
            options.profilesSampleRate = 1.0
        }
    }

    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}
```

### Capturing errors manually

```swift theme={null}
do {
    try processOrder(cart)
} catch {
    SentrySDK.capture(error: error)
}
```

### Setting user context

```swift theme={null}
let user = User(userId: "42")
user.email = "user@example.com"
SentrySDK.setUser(user)
```

### Performance monitoring

```swift theme={null}
let transaction = SentrySDK.startTransaction(name: "checkout", operation: "task")

let dbSpan = transaction.startChild(operation: "db.query", description: "SELECT orders")
let orders = fetchOrders()
dbSpan.finish()

transaction.finish()
```

### iOS-specific features

| Feature                   | Description                                                |
| ------------------------- | ---------------------------------------------------------- |
| **Crash reporting**       | Captures Swift, Objective-C, and C/C++ crashes.            |
| **OOM detection**         | Detects out-of-memory terminations.                        |
| **Slow/frozen frames**    | Tracks UI rendering performance.                           |
| **Session tracking**      | Measures crash-free session and user rates.                |
| **App hangs**             | Detects when the main thread is unresponsive.              |
| **MetricKit integration** | Correlates Sentry data with Apple's MetricKit diagnostics. |
| **View controllers**      | Automatic transaction per `UIViewController` load.         |

***

## Android

See the [Java SDK page](/sdk/java) for full Android setup instructions, including installation via Gradle, manifest-based auto-init, and `SentryAndroid.init()`.

The Android SDK supports the same mobile-specific features as iOS:

| Feature                 | Description                                         |
| ----------------------- | --------------------------------------------------- |
| **Crash reporting**     | Java, Kotlin, and NDK (C/C++) crashes.              |
| **ANR detection**       | Application Not Responding events with thread dump. |
| **OOM detection**       | Out-of-memory terminations (experimental).          |
| **Slow/frozen frames**  | UI frame rate tracking.                             |
| **Session tracking**    | Crash-free session and user rates.                  |
| **Screenshot on crash** | Optional screenshot attached to crash events.       |

***

## React Native

### Installation

<Tabs>
  <Tab title="Expo">
    ```bash theme={null}
    npx expo install @sentry/react-native
    ```

    Then run the Sentry wizard to configure native modules:

    ```bash theme={null}
    npx @sentry/wizard -i reactNative
    ```
  </Tab>

  <Tab title="React Native CLI">
    ```bash theme={null}
    npm install @sentry/react-native
    npx @sentry/wizard -i reactNative
    ```

    The wizard links native modules and creates upload scripts for source maps.
  </Tab>
</Tabs>

### Initialization

Call `Sentry.init()` in your app entry point (`index.js` or `App.tsx`), before the root component renders:

```javascript theme={null}
import * as Sentry from "@sentry/react-native";

Sentry.init({
  dsn: "https://examplePublicKey@o0.ingest.sentry.io/0",
  environment: "production",
  release: "my-app@1.0.0",
  tracesSampleRate: 1.0,
  profilesSampleRate: 1.0,
});
```

Then wrap your root component with `Sentry.wrap` to capture render errors:

```javascript theme={null}
export default Sentry.wrap(App);
```

### Capturing errors manually

```javascript theme={null}
try {
  processOrder(cart);
} catch (error) {
  Sentry.captureException(error);
}
```

### Setting user context

```javascript theme={null}
Sentry.setUser({ id: "42", email: "user@example.com" });
```

### Performance monitoring

```javascript theme={null}
const transaction = Sentry.startTransaction({ name: "checkout" });
const span = transaction.startChild({ op: "http.request", description: "POST /api/order" });

try {
  await submitOrder(cart);
} finally {
  span.finish();
  transaction.finish();
}
```

### React Native-specific features

| Feature                        | Description                                                          |
| ------------------------------ | -------------------------------------------------------------------- |
| **Native crash reporting**     | Captures crashes from both the JS layer and native iOS/Android code. |
| **Slow/frozen frames**         | Tracks UI rendering on both iOS and Android.                         |
| **Session tracking**           | Crash-free session and user rates.                                   |
| **Touch event breadcrumbs**    | Automatically records user touch interactions.                       |
| **Navigation instrumentation** | Automatic transactions for React Navigation and Expo Router.         |

***

## Session tracking

All three mobile SDKs track **sessions** automatically. A session starts when your app comes to the foreground and ends when it goes to the background or crashes.

Sentry uses session data to calculate your app's **crash-free rate** — the percentage of sessions that ended without a crash. You can view this on the **Releases** page in Sentry.

<Note>
  Session tracking is enabled by default on all mobile SDKs. To disable it, set `options.enableAutoSessionTracking = false` (iOS/Android) or `autoSessionTracking: false` (React Native).
</Note>

***

## Debug symbols

For readable stack traces in production builds, upload debug symbols for each release:

<Tabs>
  <Tab title="iOS (dSYMs)">
    ```bash theme={null}
    npx @sentry/cli upload-dif ./path/to/dSYMs
    ```

    Or configure automatic upload in your Xcode build phase using the Sentry wizard.
  </Tab>

  <Tab title="Android (ProGuard)">
    ```bash theme={null}
    npx @sentry/cli upload-proguard ./app/build/outputs/mapping/release/mapping.txt
    ```

    The `sentry-android-gradle-plugin` can upload mapping files automatically on build.
  </Tab>

  <Tab title="React Native">
    The `@sentry/wizard` sets up source map and debug symbol upload as part of your build scripts. Run the wizard if you skipped it during installation:

    ```bash theme={null}
    npx @sentry/wizard -i reactNative
    ```
  </Tab>
</Tabs>

<Tip>
  Without debug symbols, stack traces in production will show obfuscated or missing function names. Upload symbols for every release build.
</Tip>
