# Quickstart: iOS (https://www.getfounderhq.com/docs/analytics/getting-started/quickstart-ios)

Add the package, create the client once, and see your first event in
FounderHQ. About 5 minutes.

<Callout title="Before you start">
You need a FounderHQ account, Xcode, an app targeting iOS 15 or later,
and a publishable key. In the app, open **Sequences → Settings → Event
API keys**, create a key for **Browser/mobile**, and copy it. The full
key is shown only once.
</Callout>

## 1. Add FounderHQEvents

In Xcode, open **File → Add Package Dependencies** and add the
`https://github.com/FounderHQ/founderhq-events-ios` repository, version
**0.8.0** or later. Add the **FounderHQEvents** library to your
app target.

CocoaPods instead? Add `pod 'FounderHQEvents', '~> 0.8.0'` to your `Podfile` and run
`pod install`.

## 2. Create the client once

Create one shared client and hold it for the life of the app.

```swift
import FounderHQEvents

let events = FounderHQEvents(apiKey: "fhq_pk_XXXX")
```

App lifecycle, UIKit screens, sessions, and on-device queuing start
immediately. The queue survives a restart, so events captured offline
still arrive.

To change the defaults, pass a configuration.

```swift
let events = FounderHQEvents(
    apiKey: "fhq_pk_XXXX",
    configuration: FounderHQEventsConfiguration(captureScreens: false)
)
```

## 3. Track SwiftUI screens

UIKit screens are captured for you. SwiftUI views are not, so mark the
ones you care about.

```swift
PricingView()
    .founderHQScreen("Pricing", client: events)
```

## 4. Identify and capture

```swift
events.identify("user_8421", properties: ["email": "jane@acme.com"])
events.capture("trial.started", properties: ["plan": "pro"])
```

Pass your own stable user ID, not an email. Call `events.reset()` on
sign-out.

Handling a universal link? Pass it on, so the campaign that brought the
person survives the install.

```swift
events.captureDeepLink(url)
```

## Verify

1. Run the app on a simulator or device and trigger the event.
2. In FounderHQ, open **Sequences → Events**.
3. You see `trial.started` with `plan: pro`, a `$session_start`, and a
   `$screen` for the screen you opened.
4. Open **Sequences → Contacts**. Jane is there with her email.

Events can take a few seconds to appear. The SDK batches them. To send
immediately, `await events.flush()`.

## Troubleshoot

### No `$screen` events from SwiftUI

Only UIKit screens are automatic. Add `.founderHQScreen(_:client:)` to
each SwiftUI view you want to see.

### Purchases are not attributed

In-app purchases need the purchase claim flow, not `capture`. See
[Mobile purchase claims](/analytics/revenue/mobile-purchase-claims).

## Next

- [iOS SDK reference](/analytics/sdks/ios)
- [Identity and contacts](/analytics/concepts/identity-and-contacts)
