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

# Getting Started With the SwiftUI UI Kit

> Step-by-step guide to add the CometChat iOS UI Kit v6 SwiftUI toolkit to your app: install, initialise, log in, and render your first chat screen.

> [accordion] AI Integration Quick Reference
>
> | Field | Value |
> | - | - |
> | Package | `https://github.com/cometchat/cometchat-uikit-ios.git`, from `6.0.0-beta.1` (SPM only) |
> | Product | `CometChatSwiftUI` (re-exports `CometChatCore`) |
> | UI layer | SwiftUI views, modifiers and bindings |
> | Init | `try await CometChatSession.initialize(appID:region:)` — must finish before `login` |
> | Login | `try await CometChatSession.login(uid:authKey:)` — must finish before rendering components |
> | Order | `initialize` → `login` → render. Breaking this order = an empty screen |
> | Auth Key | Development only. Production: `CometChatSession.login(authToken:)` |
> | Calling | Optional. `initialize(appID:region:enableCalling: true)` |
> | Requirements | iOS 18+, Swift 6, Xcode 26+ |

This guide adds the SwiftUI toolkit to an iOS app. Every component is a SwiftUI view that fetches,
paginates and stays live on its own. By the end you have a working chat screen.

***

## Prerequisites

You need your app's **App ID**, **Auth Key** and **Region** from the
[CometChat Dashboard](https://app.cometchat.com/) (**Your App → Credentials**), Xcode 26 or later, and
an iPhone or simulator running iOS 18 or later.

> [!WARNING]
>
> Auth Key is for development only. In production, generate Auth Tokens on your server with the
> [REST API](https://api-explorer.cometchat.com/) and log in with `CometChatSession.login(authToken:)`.
> Never ship an Auth Key in an app binary.

***

## Step 1 — Create an iOS Project

1. In Xcode, choose **File ▸ New ▸ Project…** and select **iOS ▸ App**.
2. Enter a product name, and choose **SwiftUI** for Interface and **Swift** for Language.
3. Set the target's **Minimum Deployments** to **iOS 18.0**.

***

## Step 2 — Add the Package

1. Choose **File ▸ Add Package Dependencies…** and paste
   `https://github.com/cometchat/cometchat-uikit-ios.git`.
2. Set **Dependency Rule** to **Up to Next Major Version** from `6.0.0-beta.1`.
3. Add the **`CometChatSwiftUI`** product to your app target.

That is the only dependency you declare. `CometChatCore`, the CometChat Chat SDK, the Cards SDK and
the Calls SDK resolve with it. The Calls SDK is included even when you don't use calling; see
[Calling](https://www.cometchat.com/docs/ui-kit/ios/v6/calling-integration.md) to leave it out.
In a `Package.swift`:

```swift Package.swift theme={null}
.package(url: "https://github.com/cometchat/cometchat-uikit-ios.git", from: "6.0.0-beta.1")
// and in your target:
.product(name: "CometChatSwiftUI", package: "cometchat-uikit-ios")
```

Then add the camera, microphone and photo-library usage descriptions to `Info.plist` — see Step 3 of
[Getting Started](https://www.cometchat.com/docs/ui-kit/ios/v6/getting-started.md).

***

## Step 3 — Initialise and Log In

Xcode's template gives you an `App` that shows `ContentView`. Make `ContentView` initialise the Kit and
log in from a `.task`, and render the chat once both finish. SwiftUI redraws when the state changes, so
there are no callbacks to wire:

```swift ContentView.swift theme={null}
import SwiftUI
import CometChatSwiftUI

struct ContentView: View {
    @State private var isReady = false
    @State private var errorText: String?

    var body: some View {
        Group {
            if let errorText {
                Text(errorText)
            } else if isReady {
                CometChatConversations() // Step 4 replaces this with your chat experience
            } else {
                ProgressView()
            }
        }
        .task {
            do {
                try await CometChatSession.initialize(appID: "APP_ID", region: "REGION")
                // The SDK keeps the session across launches — log in only when there is none.
                if CometChatSession.loggedInUser == nil {
                    _ = try await CometChatSession.login(uid: "UID", authKey: "AUTH_KEY")
                }
                isReady = true
            } catch {
                errorText = error.localizedDescription
            }
        }
    }
}
```

Replace `APP_ID`, `REGION` and `AUTH_KEY` with your credentials, and `UID` with a user's ID — every new
app has test users `cometchat-uid-1` to `cometchat-uid-5`. Run the app: you see the logged-in user's
conversations, live.

![The conversation list the minimal SwiftUI example renders](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/override-none.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=52632d9b876614d3adc2ff672fa4795f)

> [!WARNING]
>
> `initialize` must finish before `login`, and `login` before any component renders — a component that
> renders first has no session and shows nothing. `region` must match your app's region: a mismatch fails
> at login, not at `initialize`, which makes it look like an authentication problem.

***

## Step 4 — Choose a Chat Experience

Pick the layout that suits your app. Each guide builds it step by step.

### Conversation List + Message View

Sequential navigation — the conversation list is the entry point, and a tap opens a full-screen chat.

> [card] [Build Conversation List + Message View](https://www.cometchat.com/docs/ui-kit/ios/v6/conversation-message-view.md)
>
> `CometChatConversations` in a `NavigationStack`, pushing a chat screen

### One-to-One / Group Chat

A single chat window with no list. It opens a specific user's or group's chat directly — ideal for
support chat, direct messages, or notification-driven flows.

> [card] [Build One-to-One / Group Chat](https://www.cometchat.com/docs/ui-kit/ios/v6/one-to-one-chat.md)
>
> Header, message list and composer for one chat

### Tab-Based Chat

A `TabView` with Chats, Calls, Users and Groups.

> [card] [Build Tab-Based Chat](https://www.cometchat.com/docs/ui-kit/ios/v6/tab-based-chat.md)
>
> Each tab hosts a CometChat component

***

## Make It Yours

Every part of a screen is replaceable, either as an initialiser argument or as a modifier that cascades
to everything below it:

```swift theme={null}
CometChatConversations(onItemClick: open)
    .cometChatConversationTrailingView { conversation in
        MyUnreadPill(count: conversation.unreadCount)
    }
```

When both are supplied, **the initialiser argument wins**. The full order is: initialiser argument,
then modifier, then theme, then the Kit's default.

See [Conversations](https://www.cometchat.com/docs/ui-kit/ios/v6/conversations.md) for the whole surface, and
[Theming](https://www.cometchat.com/docs/ui-kit/ios/v6/theming.md) for colours and typography.

***

## Next Steps

> [card] [Components Overview](https://www.cometchat.com/docs/ui-kit/ios/v6/components-overview.md)
>
> Browse all available UI Kit components

> [card] [Theming](https://www.cometchat.com/docs/ui-kit/ios/v6/theming.md)
>
> Customize colors, fonts, and styles

> [card] [Core Features](https://www.cometchat.com/docs/ui-kit/ios/v6/core-features.md)
>
> Chat features included out of the box

> [card] [Troubleshooting](https://www.cometchat.com/docs/ui-kit/ios/v6/troubleshooting.md)
>
> Common issues and fixes


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.