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

# iOS (Swift) — Installation

> Add Lerix to your native iOS app in a few steps — no Flutter required.

## Requirements

* iOS 13+
* Xcode 15+, Swift 5.9+
* Swift Package Manager or CocoaPods

<Note>
  This is the native Swift package for apps with no Flutter involved. If your app is built with Flutter, use the [Flutter SDK](/frameworks/flutter/installation) instead — it already covers iOS, Android, and Web from one package.
</Note>

## 1. Add the package

In Xcode: **File → Add Package Dependencies…** and enter the package's Git URL, or add it directly to your `Package.swift`:

```swift Package.swift theme={"dark"}
dependencies: [
    .package(url: "https://github.com/lerixDev/lerix_ios", from: "1.1.0")
]
```

Then add `Lerix` as a dependency of your app target.

### Or with CocoaPods

```ruby Podfile theme={"dark"}
pod 'Lerix', '~> 1.1'
```

Run `pod install` and open the generated `.xcworkspace`.

## 2. Initialize the SDK

Call `Lerix.initialize()` as early as possible — `application(_:didFinishLaunchingWithOptions:)` in your `AppDelegate`. This registers your app/device with the backend and installs automatic crash reporting.

```swift AppDelegate.swift theme={"dark"}
import UIKit
import Lerix

class AppDelegate: NSObject, UIApplicationDelegate {
    func application(
        _ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
    ) -> Bool {
        Lerix.initialize(
            apiKey: "your-api-key",
            projectId: "your-project-id",
            debugMode: true
        )
        return true
    }
}
```

<Note>
  Find your API key and project ID in the [Lerix Dashboard](https://app.lerix.dev) under **Project Settings**.
</Note>

If your app uses the SwiftUI `App` lifecycle instead of a classic `AppDelegate`, attach one with `@UIApplicationDelegateAdaptor`:

```swift theme={"dark"}
@main
struct MyApp: App {
    @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate

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

### Parameters

| Parameter | Type | Required | Description |
| - | - | - | - |
| `apiKey` | `String` | Yes | Your project API key from the dashboard |
| `projectId` | `String` | Yes | Your project ID (slug) from the dashboard |
| `url` | `String` | No | Backend base URL. Defaults to `https://api.lerix.dev/v1` — only change this if you're pointing at a self-hosted backend |
| `debugMode` | `Bool` | No | Print SDK request/response logs to the console (default: `false`) |
| `enableCrashReporting` | `Bool` | No | Install the automatic crash handler (default: `true`) — see [Error Tracking](/frameworks/ios/error-tracking) |
| `onError` | `((Error) -> Void)?` | No | Called if initialization itself fails (e.g. network unreachable) |

## 3. Verify the integration

Throw a test error to confirm everything is working:

```swift theme={"dark"}
Lerix.throwError("Test error", stack: Thread.callStackSymbols)
```

Then open your [dashboard](https://app.lerix.dev) — the error should appear within seconds.

<Check>
  You're all set! Continue to [Error Tracking](/frameworks/ios/error-tracking) to report custom errors and enable automatic crash capture, or [Push Notifications](/frameworks/ios/push-notifications) to enable push delivery.
</Check>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.