ClaudeSwiftSDK is a single Swift package that ships four libraries:
| Library | What it does |
|---|---|
| ClaudeSwift | Full Claude API — messages, streaming, vision, tools, sessions, context management |
| MemoryKit | RAG pipeline, vector search, knowledge bases |
| AgentKit | Agent framework — ReAct, plan-and-execute, multi-agent, tool system |
| AgentKitUI | SwiftUI components — chat views, activity timelines, tool inspectors |
Zero external dependencies. Swift 6 strict concurrency. Every agent is an actor.
There is no other Swift agent framework. LangGraph, CrewAI, Claude Agent SDK — all Python or TypeScript. This is the only option for native Apple development.
let agent = CodeAgent(client: client, workingDirectory: "~/Projects/MyApp")
let result = try await agent.run("Find the failing test, fix the bug, verify the build passes")CodeAgent comes pre-wired with file system, shell, and code execution tools. It reads files, runs swift build, edits code, and iterates until the job is done.
let supportAgent = ReActAgent(
client: client,
tools: [
orderLookupTool,
refundTool,
escalationTool,
knowledgeBaseTool
],
configuration: AgentConfiguration(
model: .sonnet4_5,
systemPrompt: "You are a support agent for Acme Corp. Look up orders, process refunds up to $50, escalate anything else.",
maxIterations: 15
)
)
// Drop-in SwiftUI chat interface
struct SupportView: View {
var body: some View {
AgentChatView(agent: supportAgent)
}
}let supervisor = Supervisor(
client: client,
agents: [
ReActAgent(name: "researcher", client: client, tools: [searchTool, webScrapeTool]),
ReActAgent(name: "analyst", client: client, tools: [calculatorTool, chartTool]),
ReActAgent(name: "writer", client: client, tools: [fileSystemTool]),
],
model: .opus4_6
)
let result = try await supervisor.run(
task: "Research Q4 revenue trends for the top 5 SaaS companies, analyze growth patterns, write a summary report"
)The supervisor delegates subtasks to the right agent, aggregates results, and synthesizes a final output.
let store = VectorStore()
let kb = KnowledgeBase(store: store)
// Ingest your docs
for doc in companyDocs {
try await kb.addDocument(doc.text, category: doc.category)
}
// Agent with long-term memory
let bridge = AgentMemoryBridge(knowledgeBase: kb)
let context = try await bridge.retrieveContext(for: userQuestion)
let agent = ReActAgent(
client: client,
tools: [searchTool, calculatorTool],
configuration: AgentConfiguration(
systemPrompt: "You are a knowledge assistant.\n\n\(context)"
)
)// Works on every Apple platform including visionOS
let agent = ReActAgent(client: client, tools: spatialTools)
struct ImmersiveAssistant: View {
@State var vm = AgentViewModel()
var body: some View {
VStack {
AgentActivityView(viewModel: vm)
Button("Analyze Scene") {
vm.run(agent: agent, input: "Describe what's in the user's environment")
}
}
}
}This isn't a toy wrapper. It's infrastructure for shipping real apps.
SDK layer:
- Automatic retry with exponential backoff and jitter (429, 5xx)
- Keychain credential storage for production key management
- Request interceptors and response observers for logging, metrics, auth
- SwiftData session persistence with import/export
- Context window management with automatic trimming strategies
- Prompt caching support (
cacheControl: .ephemeral)
Agent layer:
- Configurable stop conditions: max iterations, max tokens, keyword triggers, custom predicates
- Full tool call audit trail with timing data (ToolCallRecord)
- AgentSnapshot for serializing agent state to JSON
- Working memory (key-value facts + scratchpad) per agent
- MemoryKit bridge for persistent knowledge across sessions
Multi-agent layer:
- AgentTeam: parallel execution (
runAll) and sequential pipelines - Supervisor: LLM-orchestrated delegation with automatic tool routing
- Handoff protocol for agent-to-agent transfers with context
UI layer:
@ObservableAgentViewModel — bind to any SwiftUI view- AgentChatView: full chat interface with activity panel in one line
- AgentActivityView: live event timeline with icons, durations, token counts
- ToolCallView: expandable cards with input/output inspection
Testing:
- MockURLProtocol for deterministic API testing without network calls
- 116 tests across the full stack
- Every public type is
Sendable— no concurrency warnings in Swift 6 strict mode
// Package.swift
dependencies: [
.package(url: "https://github.com/ClaudeSwift/ClaudeSwiftSDK.git", from: "1.0.0")
]
// Import what you need
.target(name: "MyApp", dependencies: [
"ClaudeSwift", // SDK only
"MemoryKit", // + RAG and vector search
"AgentKit", // + Agent framework
"AgentKitUI", // + SwiftUI components
])| Minimum | |
|---|---|
| Swift | 6.0+ |
| iOS | 16.0+ (UI: 17.0+) |
| macOS | 13.0+ (UI: 14.0+) |
| watchOS | 9.0+ |
| tvOS | 16.0+ |
| visionOS | 1.0+ |
Issue tracker · Source code · Security: security@claudeswift.org
MIT License. Not affiliated with Anthropic PBC.