sdk/runanywhere-swift/README.md
Run large language models, speech recognition, text-to-speech, and voice agents directly on iPhone, iPad, and Mac — with low latency and on-device privacy. The Swift SDK provides a unified API over pluggable backends (llama.cpp, ONNX, Apple MLX) so you can ship AI features without sending user data to the cloud for inference.
| Requirement | Minimum |
|---|---|
| iOS | 17.5+ |
| macOS | 14.5+ |
| Swift | 6.2 |
| Xcode | 26+ |
In Xcode: File → Add Package Dependencies… and enter:
https://github.com/RunanywhereAI/runanywhere-sdks
Select version 0.20.11 (or from: "0.20.11"), then add the products you need. Resolve against the newest tag on the Releases page if 0.20.11 binary assets are not published yet.
| Product | Required | Capabilities |
|---|---|---|
RunAnywhere | Yes | Core SDK, model lifecycle, events |
RunAnywhereLlamaCPP | For LLM/VLM | GGUF models via llama.cpp + Metal |
RunAnywhereONNX | For STT/TTS/VAD | Whisper, Piper, Sherpa-ONNX |
RunAnywhereMLX | For MLX models | Apple MLX LLM, VLM, STT, TTS |
dependencies: [
.package(url: "https://github.com/RunanywhereAI/runanywhere-sdks", from: "0.20.11")
],
targets: [
.target(
name: "YourApp",
dependencies: [
.product(name: "RunAnywhere", package: "runanywhere-sdks"),
.product(name: "RunAnywhereLlamaCPP", package: "runanywhere-sdks"),
.product(name: "RunAnywhereONNX", package: "runanywhere-sdks"),
]
)
]
import RunAnywhere
import LlamaCPPRuntime
@main
struct MyApp: App {
init() {
Task { @MainActor in
// 1. Register the LLM backend
LlamaCPP.register()
// 2. Initialize the SDK
try RunAnywhere.initialize(
apiKey: "<YOUR_API_KEY>",
baseUrl: "https://api.runanywhere.ai",
environment: .production
)
// 3. Generate text. The model auto-loads (and downloads when
// absent); call `RunAnywhere.models.load(id:)` first if you
// want to control when that cost is paid.
let result = try await RunAnywhere.llm.generate(
prompt: "What is the capital of France?",
options: LlmOptions(model: "llama-3.2-1b-instruct-q4", maxOutputTokens: 128)
)
print(result.text)
}
}
var body: some Scene {
WindowGroup { ContentView() }
}
}
For development without an API key, call try RunAnywhere.initialize(environment: .development).
| Capability | Backends | Model formats | Notes |
|---|---|---|---|
| LLM | RunAnywhereLlamaCPP, RunAnywhereMLX | GGUF (.gguf) | Streaming, structured output, tool calling |
| STT | RunAnywhereONNX, RunAnywhereMLX | ONNX (.onnx, .ort) | Whisper, Sherpa streaming |
| TTS | RunAnywhereONNX, RunAnywhereMLX | ONNX, Piper voices | System TTS also available |
| VLM | RunAnywhereLlamaCPP, RunAnywhereMLX | GGUF multimodal | Image + text inference |
| Voice | Core + STT + LLM + TTS backends | — | VAD → STT → LLM → TTS pipeline |
| NPU | — | — | Not available on Apple platforms via this SDK |
Register each backend module before using its capabilities:
LlamaCPP.register() // LLM + VLM
ONNX.register() // STT + TTS + VAD (requires RunAnywhereONNX)
MLX.register() // MLX modalities (requires RunAnywhereMLX)
| Format | Extension | Backend | Use case |
|---|---|---|---|
| GGUF | .gguf | llama.cpp | LLM, VLM text generation |
| ONNX | .onnx | ONNX Runtime | STT, TTS, VAD |
| ORT | .ort | ONNX Runtime | Optimized STT/TTS |
Models are discovered through the RunAnywhere catalog, downloaded on-device, and managed via RunAnywhere.models.load(id:), RunAnywhere.models.download(id:), and the rest of the models namespace.
ConnectSession publishes or joins a language-model session on the local network. Commons owns role policy and protocol validation; this SDK owns Bonjour and the framed TCP adapter.
| Role | Platforms |
|---|---|
| Host | macOS only |
| Client | iOS and iPadOS (Android clients use the Kotlin SDK) |
_runanywhere-connect._tcpplatformPolicy(); compile-time #if os guards only gate Apple APIs that do not exist on the other Apple platformsSee the iOS/macOS example under examples/ios/RunAnywhereAI/ (ConnectHostManagementView, model-selection Connect section).
| Resource | Link |
|---|---|
| Docs | docs.runanywhere.ai/swift/introduction |
| Example app | examples/ios/RunAnywhereAI/ |
| Contributing / local build | docs/DEVELOPMENT.md |
Inference runs on-device after models are downloaded. Network access is used for SDK authentication, model downloads, and optional analytics — prompts, responses, and audio are not sent to the cloud for inference by default.
Compliance with regulations such as HIPAA or GDPR depends on your deployment, data handling practices, and backend configuration. Review your architecture and consult legal counsel for regulated use cases.
Copyright © 2026 RunAnywhere AI. All rights reserved.
This SDK is distributed under the RunAnywhere License. For commercial licensing inquiries, contact [email protected].