iOS SDK
Installation & Quickstart
Add the QwryAI iOS SDK to your app and get your first answer from your agent
This page takes you from an empty Xcode project to a streamed answer from your agent. You turn on the iOS SDK channel in the dashboard, add the Swift package, create a QwryClient and send a message.
Prerequisites
| Requirement | Minimum |
|---|---|
| iOS | 17.0 |
| macOS | 14.0 |
| Swift | 6.0 |
| Xcode | 16 |
| SwiftUI | Not required. The SDK works with UIKit, AppKit or any UI code. |
Installation
The SDK ships as a Swift package, QwrySDK, with no dependencies.
- Open Add Package Dependencies
In Xcode, choose File → Add Package Dependencies…
- Paste the repository URL
https://github.com/qwryai/qwryai-ios-sdk.git - Pick the version and target
Choose Up to Next Major Version from
0.1.0, then add the QwrySDK library to your app target.
// Package.swift
dependencies: [
.package(url: "https://github.com/qwryai/qwryai-ios-sdk.git", from: "0.1.0")
],
targets: [
.target(
name: "YourApp",
dependencies: [
.product(name: "QwrySDK", package: "qwryai-ios-sdk")
]
)
]Then import it:
import QwrySDKQuick Start
- Open the iOS SDK channel
In the dashboard, open your agent and go to Channels. On the iOS SDK card, select Manage. You can also switch to it from the channel menu at the top of the Playground.
Channels › iOS SDK - Turn on Visibility
Select the Overview tab and switch Visibility on. Visibility saves as soon as you change it, and from then on the agent accepts requests from the SDK. Overview also holds the model and instructions this channel uses; leave Sync with global instructions on to answer exactly as your other channels do.
Visibility lets the SDK reach your agent.
- Copy your agent ID
Open the Setup tab. Under Agent ID, select Copy. The same tab links to the SDK source and the iOS example app, and repeats the install and quick start code with your agent ID already filled in.
Setup holds your agent ID and install code. - Create a client
import QwrySDK let client = QwryClient(agentId: "YOUR_AGENT_ID")Create the client once and keep it: in a view model, an app-level dependency or a
@Stateproperty.QwryClientis an actor, so you can share one client across your app. A new client starts anonymous, tied to a device ID that stays the same across launches. For the other initializer options, see theQwryClientreference. - Send your first message
let response = try await client.send("Hello! What can you help me with?") { handlers in handlers.onTextDelta = { piece in // Runs for each piece of text as it arrives print(piece, terminator: "") } } print(response.message.text) print("Conversation: \(response.conversationId)") print("Credits used: \(response.credits)")See ChatResponse for every field on the response.
- Continue the conversation
The client remembers the conversation the last answer belonged to, so the next
sendcarries on where you left off:let followUp = try await client.send("Tell me more")Call
await client.newConversation()when you want the next message to start a fresh conversation. For a chat screen, useConversationState, which also keeps the message list for you.