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

iOS

Swift and Objective-C apps via sentry-cocoa.

Android

Java and Kotlin apps via sentry-android.

React Native

Cross-platform apps via @sentry/react-native.

iOS (Swift / Objective-C)

Installation

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:
// Package.swift
dependencies: [
    .package(
        url: "https://github.com/getsentry/sentry-cocoa",
        from: "8.0.0"
    ),
],
targets: [
    .target(
        name: "YourApp",
        dependencies: ["Sentry"]
    ),
]

Initialization

Initialize Sentry in your AppDelegate or the @main entry point, before the rest of your app starts:
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

do {
    try processOrder(cart)
} catch {
    SentrySDK.capture(error: error)
}

Setting user context

let user = User(userId: "42")
user.email = "user@example.com"
SentrySDK.setUser(user)

Performance monitoring

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

FeatureDescription
Crash reportingCaptures Swift, Objective-C, and C/C++ crashes.
OOM detectionDetects out-of-memory terminations.
Slow/frozen framesTracks UI rendering performance.
Session trackingMeasures crash-free session and user rates.
App hangsDetects when the main thread is unresponsive.
MetricKit integrationCorrelates Sentry data with Apple’s MetricKit diagnostics.
View controllersAutomatic transaction per UIViewController load.

Android

See the Java SDK page 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:
FeatureDescription
Crash reportingJava, Kotlin, and NDK (C/C++) crashes.
ANR detectionApplication Not Responding events with thread dump.
OOM detectionOut-of-memory terminations (experimental).
Slow/frozen framesUI frame rate tracking.
Session trackingCrash-free session and user rates.
Screenshot on crashOptional screenshot attached to crash events.

React Native

Installation

npx expo install @sentry/react-native
Then run the Sentry wizard to configure native modules:
npx @sentry/wizard -i reactNative

Initialization

Call Sentry.init() in your app entry point (index.js or App.tsx), before the root component renders:
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:
export default Sentry.wrap(App);

Capturing errors manually

try {
  processOrder(cart);
} catch (error) {
  Sentry.captureException(error);
}

Setting user context

Sentry.setUser({ id: "42", email: "user@example.com" });

Performance monitoring

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

FeatureDescription
Native crash reportingCaptures crashes from both the JS layer and native iOS/Android code.
Slow/frozen framesTracks UI rendering on both iOS and Android.
Session trackingCrash-free session and user rates.
Touch event breadcrumbsAutomatically records user touch interactions.
Navigation instrumentationAutomatic 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.
Session tracking is enabled by default on all mobile SDKs. To disable it, set options.enableAutoSessionTracking = false (iOS/Android) or autoSessionTracking: false (React Native).

Debug symbols

For readable stack traces in production builds, upload debug symbols for each release:
npx @sentry/cli upload-dif ./path/to/dSYMs
Or configure automatic upload in your Xcode build phase using the Sentry wizard.
Without debug symbols, stack traces in production will show obfuscated or missing function names. Upload symbols for every release build.