Swift SDK
Run AI models on-device with a simple Swift API on iOS, macOS, and Android.Building
apple/):
| File | Description |
|---|---|
cactus-ios.xcframework/ | iOS framework (device + simulator) |
cactus-macos.xcframework/ | macOS framework |
libcactus-device.a | Static library for iOS device |
libcactus-simulator.a | Static library for iOS simulator |
libcactus.so from the android/ directory.
Integration
iOS/macOS: XCFramework (Recommended)
- Drag
cactus-ios.xcframework(orcactus-macos.xcframework) into your Xcode project - Ensure “Embed & Sign” is selected in “Frameworks, Libraries, and Embedded Content”
- Copy
Cactus.swiftinto your project
iOS/macOS: Static Library
- Add
libcactus-device.a(orlibcactus-simulator.a) to “Link Binary With Libraries” - Create a folder with
cactus_ffi.handmodule.modulemap, add to Build Settings:- “Header Search Paths” → path to folder
- “Import Paths” (Swift) → path to folder
- Copy
Cactus.swiftinto your project
Android (Swift SDK)
Requires Swift SDK for Android.-
Copy files to your Swift project:
libcactus.so→ your library pathcactus_ffi.h→ your include pathmodule.android.modulemap→ rename tomodule.modulemapin include pathCactus.swift→ your sources
- Build with Swift SDK for Android:
- Bundle
libcactus.sowith your APK injniLibs/arm64-v8a/
Usage
Handles are typed asCactusModelT, CactusIndexT, and CactusStreamTranscribeT (all UnsafeMutableRawPointer aliases).
Basic Completion
Completion with Options and Streaming
Audio Transcription
Streaming Transcription
Embeddings
Vector Index
API Reference
All functions are top-level and mirror the C FFI directly.Types
throws functions throw NSError (domain "cactus") on failure.
Init / Lifecycle
Completion
Transcription
Embeddings
Tokenization / Scoring
VAD / RAG
Vector Index
Telemetry
Requirements
Apple Platforms:- iOS 14.0+ / macOS 13.0+ / tvOS 14.0+ / watchOS 7.0+
- Xcode 14.0+
- Swift 5.7+
- Swift 6.0+ with Swift SDK for Android
- Android NDK 27d+
- Android API 28+ / arm64-v8a
See Also
C API Reference
Full C API reference underlying the Swift bindings
Vector Index API
Vector database API for RAG applications
Kotlin SDK
Kotlin alternative for Android
Flutter SDK
Cross-platform alternative using Dart