Back to Runanywhere Sdks

RunAnywhere AI — iOS Example

examples/ios/RunAnywhereAI/README.md

0.20.127.5 KB
Original Source

RunAnywhere AI — iOS Example

<p align="center"> </p> <p align="center"> <a href="https://apps.apple.com/us/app/runanywhere/id6756506307"> </a> </p> <p align="center"> </p>

A production-ready reference app for the RunAnywhere Swift SDK. LLM chat, speech, vision, voice agents, RAG, benchmarks, and model management—privacy-first and offline-capable on iPhone, iPad, and Mac.


Requirements

ItemMinimum
Xcode26+ with Swift 6.2 and iOS 17.5+ simulator runtimes
Command Line ToolsSelected in Xcode → Settings → Locations
CMake & NinjaFor root native XCFramework generation
Disk spaceSeveral GB for XCFramework output and AI models
DeviceApple Silicon recommended (physical device for MLX and best LLM performance)

Setup

Important: This sample links the local Swift SDK through Package.swift. A clean clone must build iOS XCFrameworks before Xcode can link the native backends.

1. Clone and enter the example

bash
git clone https://github.com/RunanywhereAI/runanywhere-sdks.git
cd runanywhere-sdks/examples/ios/RunAnywhereAI

2. Build native XCFrameworks (repo root)

bash
cd ../../..
./sdk/runanywhere-swift/scripts/build-core-xcframework.sh
cd examples/ios/RunAnywhereAI

Expected artifacts under sdk/runanywhere-swift/Binaries/:

ArtifactNeeded for
RACommons.xcframeworkCore (required)
RABackendLLAMACPP.xcframeworkLLM and VLM
RABackendONNX.xcframework · RABackendSherpa.xcframeworkSTT, TTS, VAD
onnxruntime.xcframework · onnx.xcframeworkONNX Runtime for the two above
RABackendMLX.xcframework · RunAnywhereMLXRuntime.xcframework · RunAnywhereMLXMetal.xcframeworkApple MLX (this app links RunAnywhereMLX)
RABackendCoreML.xcframeworkCore ML image generation

All ten are produced by one run of the script. A short list is the usual cause of link errors on the MLX path, since this app's Package.swift depends on the RunAnywhereMLX product.

Re-run this step after any C++ change in runanywhere-commons.

3. Resolve packages and build

bash
RUNANYWHERE_USE_LOCAL_NATIVES=1 swift package resolve

xcodebuild \
  -project RunAnywhereAI.xcodeproj \
  -scheme RunAnywhereAI \
  -resolvePackageDependencies

xcodebuild \
  -project RunAnywhereAI.xcodeproj \
  -scheme RunAnywhereAI \
  -configuration Debug \
  -sdk iphonesimulator \
  -destination 'generic/platform=iOS Simulator' \
  build

4. Run the app

Option A — Xcode: Open RunAnywhereAI.xcodeproj, select a simulator or device, press Run (⌘R).

Option B — Script:

bash
./scripts/build_and_run_ios_sample.sh simulator "iPhone 16 Pro" --build-sdk
# Physical device:
./scripts/build_and_run_ios_sample.sh device
# macOS:
./scripts/build_and_run_ios_sample.sh mac

Option C — Verify gate:

bash
./scripts/verify.sh

After modifying the SDK

ChangeAction
Swift SDK sourceXcode picks up changes on rebuild
C++ / commonsRe-run build-core-xcframework.sh
Stale package errorsFile → Packages → Reset Package Caches, then resolve again

Features

FeatureDescription
AI ChatStreaming LLM with thinking mode, tool calling, and LoRA adapters
Speech-to-TextBatch and live transcription (Sherpa-ONNX / Whisper)
Text-to-SpeechNeural Piper voices
Voice AssistantFull STT → LLM → TTS pipeline with particle UI
Vision (VLM)Camera and photo-library image understanding
RAGPDF/document ingestion and on-device Q&A
BenchmarksDeterministic LLM, STT, TTS, and VLM performance tests
Voice KeyboardiOS keyboard extension with dictation flow
Model ManagementDownload, load, storage, and deletion
Cross-PlatformUniversal iOS, iPadOS, and macOS app

MLX-backed models run on physical iOS devices and native macOS; the arm64 simulator build validates package and startup paths but does not execute MLX inference.


Project structure

RunAnywhereAI/
├── RunAnywhereAI/
│   ├── App/                    # Entry point, SDK init, tab shell
│   ├── Features/               # Chat, Voice, Vision, RAG, Benchmarks, …
│   ├── Core/                   # Design system, services, models
│   └── Helpers/                # Markdown rendering, adaptive layout
├── RunAnywhereKeyboard/        # Keyboard extension target
├── RunAnywhereActivityExtension/  # Live Activity widget
├── Package.swift               # Local Swift SDK dependency
├── scripts/
│   ├── build_and_run_ios_sample.sh
│   ├── verify.sh
│   └── smoke.sh
└── README.md

Architecture: MVVM with Swift Observation (@Observable view models), a single RunAnywhere.* SDK entry point, and centralized design tokens (AppColors, AppTypography, brand orange #FF6900).


Troubleshooting

SymptomFix
Missing XCFramework errorsRun ./sdk/runanywhere-swift/scripts/build-core-xcframework.sh from repo root
Package resolution failuresReset package caches in Xcode; rerun swift package resolve
Sandbox / derived-data issuesClean build folder (⇧⌘K); delete DerivedData if needed
MLX models unavailableUse a physical device; MLX returns unavailable on simulator
Verify script failsRun ./scripts/verify.sh and follow its output for the exact gate

Quick static check without full compile:

bash
./scripts/smoke.sh

Filter runtime logs in Console.app: subsystem:com.runanywhere.RunAnywhereAI.


ResourceLink
Swift SDKsdk/runanywhere-swift/README.md
Android exampleexamples/android/RunAnywhereAI
React Native exampleexamples/react-native/RunAnywhereAI
Flutter exampleexamples/flutter/RunAnywhereAI
App StoreRunAnywhere on the App Store
Discorddiscord.gg/N359FBbDVd
IssuesGitHub Issues
Email[email protected]

License

This project is licensed under the RunAnywhere License (Apache 2.0 based, with additional commercial-use terms). See LICENSE for details.