# iOS

## Setup

Jitsu supports Segment [Analytics-Swift](https://segment.com/docs/connections/sources/catalog/libraries/mobile/apple/) library to receive events from iOS, tvOS, iPadOS, WatchOS, macOS and Linux applications.

Please follow the [Installation instruction](https://segment.com/docs/connections/sources/catalog/libraries/mobile/apple/#getting-started) to install the library.


:::tip
In all examples below, replace `your-jitsu-domain.com` with your Jitsu installation domain.

Jitsu Cloud users may find domain in the top-right corner of Site's **Setup Instruction** page or
attach custom domain for a specific Site and use it instead.
::: 

## Setting up the client

Jitsu requires additional settings to direct events to a correct Jitsu instance.

```swift
    var analytics: Analytics? = nil

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
            // Override point for customization after application launch.
            let configuration = Configuration(
              writeKey: "BROWSER_WRITE_KEY", 
              apiHost: "your-jitsu-domain.com",
              cdnHost: "your-jitsu-domain.com")
                .trackApplicationLifecycleEvents(true)
                .flushInterval(10)

            analytics = Analytics(configuration: configuration)
    }

```

where:

|            | Description                                                                                                                                                                                                         |
|------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `apiHost`    | Jitsu server URL. E.g.: `your-jitsu-domain.com`                                                                                                                                                              |
| `cdnHost` | CDN host for settings retrieval. Jitsu server URL. E.g.: `your-jitsu-domain.com`                                                                                                                                |
| `writeKey` | Browser Write Key configured on Jitsu Site entity. If no Browser Write Key is added for Site entity, Site ID value can be used a Write Key. On Jitsu.Cloud can be omitted if Site has explicitly mapped domain name. |


## Event tracking

Please refer to the [Analytics-Swift for iOS & Apple](https://segment.com/docs/connections/sources/catalog/libraries/mobile/apple/) documentation for more details on how to track events with Jitsu.