Skip to main content

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:
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.
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()
        }
    }
}
Replace YOUR_API_TOKEN with your actual API token from the Stringboot Dashboard.

Configuration (Optional)

You can also configure the SDK via Info.plist:
<key>StringbootAPIURL</key>
<string>https://api.stringboot.com</string>
<key>StringbootAPIToken</key>
<string>YOUR_API_TOKEN</string>
<key>StringbootCacheSize</key>
<integer>1000</integer>