iOS (Swift)
Install
In Xcode: File → Add Package Dependencies → https://github.com/heysada/sada-ios, then add the HeysadaRafiq library to your target.
One Swift package holds all our SDKs, so it has one version for every product: you update them together. Every library links the same binary, HeysadaKit, so an app carries every product’s code, whichever libraries it uses (an iOS app can hold one Kotlin runtime, so the products share one framework).
The assistant in a SwiftUI app: the person’s chats with the AI, what it knows of their workspace and its settings, drawn from your app’s published design. It runs the Kotlin Multiplatform SDK inside (the same screens as on Android) with a Swift face: the session, your client tools and your own API calls are Swift closures. iOS 15 and later.
import HeysadaRafiq
import SwiftUI
let assistant = RafiqAssistant(
baseUrl: "https://assistant.example.com", // the panel's Install screen fills these in
appKey: "pk_…",
// Optional: the signed-in person, from your server (HS256, the app's identity secret).
userToken: { try await myBackend.rafiqToken() },
// Your app's tools: offered to the model with every message, run here on the device.
tools: [
"open_screen": RafiqClientTool(
description: "Opens one of the app's screens",
parameters: ["type": "object", "properties": ["screen": ["type": "string"]]]
) { input in navigate(to: input["screen"] as? String); return "opened" },
],
// A client connection's calls (a change the person confirmed first) go to your API with your
// own session, and never anywhere else.
hostCaller: urlSessionHostCaller(base: URL(string: "https://api.example.com")!) {
["Authorization": "Bearer \(myToken())"]
}
)
struct HelpScreen: View {
var body: some View { RafiqChatView(assistant: assistant) }
}
With appKey alone the SDK starts its own session: a guest Rafiq names, kept in the app’s
UserDefaults, or the signed-in person when userToken gives your server’s token. The app’s bundle
id goes as X-App-Id, which a live app’s key is held to. RafiqAssistant(baseUrl:session:)
stays for a session your backend mints with the app’s secret.
RafiqChatView(assistant:chatId:onClose:),RafiqKnowledgeView,RafiqSettingsView: the screens, each a SwiftUI view.assistant.rafiqis the Kotlin SDK itself: every route (rafiq.api), and a chat to follow from your own screens (rafiq.chat(chatId:), thenwatch(onChange:)for its state on the main thread).- The session JWT is the only credential: no app key, and nothing else is called.