iOS quickstart

Your first crash report in about five minutes

Pharen is crash reporting, build distribution, and product analytics for iOS, behind one small SDK with no third-party dependencies. This page takes you from an empty project to a real crash report you can open. Everything here runs against the shipping SDK — the code compiles as written.

1. Add the SDK

PharenSDK is distributed with Swift Package Manager (Foundation only — zero third-party dependencies). In Xcode, File → Add Package Dependencies…, or add it to your Package.swift:

swiftPackage.swift
dependencies: [
    .package(url: "https://github.com/pharen-ai/sdk-ios.git", from: "0.1.0")
]

Then add "PharenSDK" to your app target's dependencies. Pin a SemVer major range.

2. Set two Info.plist values

Pharen configures itself from your app's Info.plist — no config code, no secrets in source you have to guard. Add the ingest key and declare which consent purposes you grant at launch. Crash reporting needs telemetry:

xmlInfo.plist
<key>PharenIngestKey</key>
<string>YOUR-INGEST-KEY</string>

<key>PharenConsentGranted</key>
<array>
    <string>telemetry</string>
</array>

The ingest key is public by design — like a crash-reporter DSN, it ships inside your binary. It carries no access to your data; the server derives your tenant, app, and environment from it. Commit it. (Use your phi_test_… key in Debug and your phi_live_… key in Release — see Distribution.)

3. Start Pharen

One line, as early as possible in your app's lifecycle:

swiftMyApp.swift
import PharenSDK
import SwiftUI

@main
struct MyApp: App {
    init() {
        Pharen.start()   // reads PharenIngestKey + PharenConsentGranted from Info.plist
    }

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

That's the whole install. Pharen.start() installs the crash handlers, starts a session, and begins delivering events in the background — off the main thread, in batches. If the app is unconfigured it returns nil and installs nothing.

4. Trigger a test crash

The SDK ships a deliberate crash for exactly this moment. Wire it to a button in a Debug build:

swift
#if DEBUG
Button("Force a test crash") {
    Pharen.crashTest()   // raises an uncaught exception on purpose
}
#endif

Run the app on a device (not the debugger — an attached debugger catches the signal first), tap the button, and let it crash.

5. Reopen the app — and look

Fatal crashes are written to disk at crash time and uploaded on the next launch (a crashing process can't reliably send anything itself). So relaunch the app once. Within moments the crash appears in your Pharen console, grouped into an issue.

Where to next