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

# Integrate the Klaritics iOS SDK in Your App

> Add the Klaritics iOS SDK via Swift Package Manager, initialize with app_id and server_host, and log app events from Swift or Objective-C.

The Klaritics iOS SDK collects analytics from iOS applications and sends them to your self-hosted Klaritics instance. This guide covers Swift Package Manager setup, initialization, and event logging in both Swift and Objective-C.

## Installation

Add the SDK via Swift Package Manager (SPM). CocoaPods is not part of the current setup.

1. In Xcode, choose **File → Add Packages**.
2. Enter the Klaritics iOS SDK repository URL.
3. Add the package to your application target.

## Initialization

Call `initialize` before logging any events, typically in your `AppDelegate` or app entry point:

```swift theme={null}
Klaritics.initialize(
    appId: "YOUR_APP_ID",
    serverHost: "https://YOUR_SERVER_HOST"
)
```

The SDK will not initialize until both `appId` and `serverHost` are provided.

## Logging events

Use `logAppEvent` to send standard analytics events. The method accepts an event name and an optional dictionary of additional information.

<CodeGroup>
  ```swift Swift theme={null}
  Klaritics.logAppEvent(
      withName: "ButtonClicked",
      info: ["ButtonLabel": "Hey"]
  )
  ```

  ```objc Objective-C theme={null}
  NSDictionary *info = @{
      @"ButtonLabel": @"Hey"
  };
  [Klaritics logAppEventForEvent:@"LANG_SELECT" withInfo:info];
  ```
</CodeGroup>

## Important naming note

The client-facing class is `Klaritics`. Do not use `KlariticsSDK`, `KlariticsCore`, or any other variant in your application code.
