# errorgap for iOS / macOS / tvOS / watchOS (Swift)

See [index.md](./index.md) for API details and the placeholder values (`ERRORGAP_API_KEY`, `ERRORGAP_ENDPOINT`, `ERRORGAP_PROJECT_SLUG`).

SDK source: `github.com/errorgaphq/errorgap-swift` · current version: `0.2.0`. Requires Swift 5.9+, iOS 14+, macOS 11+, watchOS 7+, tvOS 14+.

## Install

Swift Package Manager — in `Package.swift`:

```swift
.package(url: "https://github.com/errorgaphq/errorgap-swift.git", from: "0.2.0")
```

…and add `"Errorgap"` to your target's dependencies. Or in Xcode: File → Add Packages…

## Configure

In your app's launch path:

```swift
import Errorgap

Errorgap.initialize(ErrorgapConfiguration(
    endpoint:    "https://errorgap.example.com",
    projectSlug: "your-project",
    apiKey:      ProcessInfo.processInfo.environment["ERRORGAP_API_KEY"],
    release:     Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String
))
```

By default the SDK installs `NSSetUncaughtExceptionHandler` and auto-attaches device metadata (`os_name`, `app_version`, `device_model`, etc).

Pass `captureGlobals: false` to skip the global hook.

## Trigger a test error

```swift
Errorgap.notify(NSError(domain: "ErrorgapTest", code: 0, userInfo: [
    NSLocalizedDescriptionKey: "Errorgap test error"
]))
```

Or throw via an `NSException`.

## Verify

Run the verification curl from [index.md](./index.md), then trigger the test error and confirm the onboarding screen advances.
