A minimal iOS app demonstrating the ResolveKit SDK integration. This example covers:
- SDK initialization with
ResolveKitRuntimeandResolveKitConfiguration - Chat UI embedding via
ResolveKitChatViewin SwiftUI - Function definitions using the
@ResolveKitmacro - Approval flow — functions with
requiresApproval: truetrigger the built-in approval UI - Connection state observation — live banner showing stream lifecycle
Example/ResolveKitDemo/
├── Package.swift # SPM manifest (depends on parent SDK)
├── README.md # This file
└── Sources/ResolveKitDemo/
├── ResolveKitDemoApp.swift # App entry point
├── Functions/
│ ├── GetLocalTime.swift # Read-only function (auto-executes)
│ ├── SendReminder.swift # Parameterized function (requires approval)
│ └── GetDeviceStatus.swift # Device info function (requires approval)
└── Views/
└── ContentView.swift # Main chat view + connection state banner
- Xcode 15.0+
- iOS 16.0+ device or simulator
- A running ResolveKit backend with a valid API key
git clone https://github.com/resolve-kit/resolvekit-ios-sdk.git
cd resolvekit-ios-sdkThe demo reads the API key from the RESOLVEKIT_API_KEY environment variable. Set it before building:
export RESOLVEKIT_API_KEY="rk_your_dev_key"Alternatively, edit the apiKeyProvider closure in ContentView.swift to return your key directly (for local testing only — never commit real keys).
cd Example/ResolveKitDemo
swift buildGenerate an Xcode project and open it:
cd Example/ResolveKitDemo
swift package generate-xcodeproj
open ResolveKitDemo.xcodeprojThen select an iOS simulator or device and press Run (⌘R).
Once the app launches, you'll see the ResolveKit chat interface:
-
Send a message like "What time is it?" — the LLM will call
GetLocalTimeautomatically (no approval needed sincerequiresApproval: false). -
Ask it to set a reminder like "Remind me to drink water in 30 minutes" — the approval UI will appear showing
SendReminderwith its parameters. Tap Approve All to execute. -
Ask about your device like "What device am I using?" —
GetDeviceStatuswill appear in the approval UI with device details pending confirmation. -
Watch the connection state banner at the bottom during startup and if the network drops.
@StateObject private var runtime = ResolveKitRuntime(configuration: ResolveKitConfiguration(
apiKeyProvider: { "rk_your_api_key" },
functions: [GetLocalTime.self, SendReminder.self, GetDeviceStatus.self]
))ResolveKitChatView(runtime: runtime)@ResolveKit(name: "get_local_time", description: "...", requiresApproval: false)
struct GetLocalTime: ResolveKitFunction {
func perform() async throws -> String {
return Date().description
}
}For custom schemas or dynamic dispatch, conform to AnyResolveKitFunction directly. See the main README for details.
| Issue | Fix |
|---|---|
Missing API key |
Ensure apiKeyProvider returns a non-empty string. Check RESOLVEKIT_API_KEY env var. |
Chat stuck in blocked |
SDK version is incompatible with backend. Update the SDK to the latest version. |
| Functions not appearing | Verify function types are listed in ResolveKitConfiguration.functions. |
| Approval UI doesn't show | Check that requiresApproval: true is set on the @ResolveKit macro for that function. |
MIT — same as the parent SDK.