---
url: https://simpledatalogs.com/docs/quickstarts/ios-swift.md
description: >-
  Add simpledatalogs to an iOS or macOS app with the Swift SDK, with launches,
  sessions and crashes captured by one argument.
---

# iOS and macOS (Swift)

## Install

In Xcode, **File → Add Package Dependencies…** and add the `SimpleDataLogs` library. Until the public launch the package comes with your invitation as a local package (**Add Local…**, pick the package folder).

## Add it

```swift
import SimpleDataLogs

// At launch, e.g. in your App's init:
SimpleDataLogs.configure(ingestKey: "sdl_pub_…", autocapture: .all)

// Anywhere:
SimpleDataLogs.track("screenshot_taken", properties: ["type": "area"])
```

## Send everything, or only what you choose

* **Everything:** `autocapture: .all` sends launches, sessions and crashes.
* **Pick:** `autocapture: [.sessions, .crashes]`.
* **Only your own events:** leave `autocapture` out.

Screen views are opt-in per screen:

```swift
SettingsView()
    .trackScreenView("Settings")
```

## In the first minute

* `session_start` and `app_launched` (with `is_first_launch`) as soon as the app starts.
* Every event carries a `session_id`; `session_end` (with `duration_s`) follows once the app has been away 30 minutes.
* After a crash from an uncaught `NSException`, `app_crashed` with `exception_name`, `reason` and `stack` on the next launch.

## Autocapture defaults

| Option | With `.all` |
|---|---|
| `.appLaunches` | on |
| `.sessions` (iOS foreground/background, macOS activation) | on |
| `.crashes` (uncaught `NSException`) | on |
| Screen views | per screen, with `.trackScreenView` or `trackScreen(_:)` |

Swift traps (`fatalError`, force unwraps) are not `NSException`s and are not captured. Everything else is in the [Swift SDK](/sdks/swift) reference.
