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

# Installation

> Add the Stringboot SDK to your iOS project

***

## Swift Package Manager

1. Open your project in Xcode.
2. Go to **File > Add Package Dependencies**.
3. Enter the repository URL: `https://github.com/your-org/stringboot-ios-sdk.git`
4. Select the version (e.g., `1.2.2`) and add it to your target.

Alternatively, add it to your `Package.swift`:

```swift theme={null}
dependencies: [
    .package(url: "https://github.com/your-org/stringboot-ios-sdk.git", from: "1.2.2")
]
```

## Initialization

Initialize the SDK in your `App` struct (SwiftUI) or `AppDelegate` (UIKit). This snippet sets up everything you need.

<Tabs>
  <Tab title="SwiftUI">
    ```swift theme={null}
    import SwiftUI
    import StringbootSDK

    @main
    struct MyApp: App {
        init() {
            // 1. Setup Analytics (for A/B Testing)
            let analyticsHandler = MyAnalyticsHandler()

            // 2. Initialize Core SDK
            StringProvider.shared.initialize(
                cacheSize: 1000,
                apiToken: "YOUR_API_TOKEN",
                baseURL: "https://api.stringboot.com",
                analyticsHandler: analyticsHandler,
                providedDeviceId: "USER_ID" // Optional
            )

            // 3. Initialize FAQ Provider
            FAQProvider.shared.initialize(
                cacheSize: 200,
                apiToken: "YOUR_API_TOKEN",
                baseURL: "https://api.stringboot.com"
            )

            // 4. Setup FAQ Auto-Sync (Recommended)
            Task {
                let locale = StringProvider.shared.deviceLocale()

                // Preload FAQs from cache for instant access
                await FAQProvider.shared.preloadFromDatabase(lang: locale, maxFAQs: 100)

                // Sync latest FAQs from server in background
                await FAQProvider.shared.refreshFromNetwork(lang: locale)
            }

            // 5. Configure Logging
            #if DEBUG
            StringbootLogger.isLoggingEnabled = true
            StringbootLogger.logLevel = .debug
            #endif
        }

        var body: some Scene {
            WindowGroup {
                ContentView()
            }
        }
    }
    ```
  </Tab>

  <Tab title="UIKit">
    ```swift theme={null}
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // 1. Setup Analytics
        let analyticsHandler = MyAnalyticsHandler()

        // 2. Initialize Core SDK
        StringProvider.shared.initialize(
            cacheSize: 1000,
            apiToken: "YOUR_API_TOKEN",
            baseURL: "https://api.stringboot.com",
            analyticsHandler: analyticsHandler
        )

        // 3. Initialize FAQ Provider
        FAQProvider.shared.initialize(
            cacheSize: 200,
            apiToken: "YOUR_API_TOKEN",
            baseURL: "https://api.stringboot.com"
        )

        // 4. Setup FAQ Auto-Sync (Recommended)
        Task {
            let locale = StringProvider.shared.deviceLocale()

            // Preload FAQs from cache for instant access
            await FAQProvider.shared.preloadFromDatabase(lang: locale, maxFAQs: 100)

            // Sync latest FAQs from server in background
            await FAQProvider.shared.refreshFromNetwork(lang: locale)
        }

        return true
    }
    ```
  </Tab>
</Tabs>

<Note>
  Replace `YOUR_API_TOKEN` with your actual API token from the Stringboot Dashboard.
</Note>

## Configuration (Optional)

You can also configure the SDK via `Info.plist`:

```xml theme={null}
<key>StringbootAPIURL</key>
<string>https://api.stringboot.com</string>
<key>StringbootAPIToken</key>
<string>YOUR_API_TOKEN</string>
<key>StringbootCacheSize</key>
<integer>1000</integer>
```
