Run the Pi coding agent natively on iOS.
- Native Performance: Runs Bun's JavaScript engine directly on iOS using JSC's C_LOOP interpreter
- GPU-Accelerated Terminal: Uses Ghostty's Metal-based terminal renderer
- Full Pi Agent: Complete pi coding agent with tool use, file operations, and more
- Works Offline: No WebView, no remote execution - everything runs locally on device
- iOS 17.0+
- iPhone with arm64 processor
- OpenRouter API key (for AI model access)
-
Clone the repository
git clone https://github.com/dannote/pi-ios.git cd pi-ios -
Download pre-built dependencies
Download the vendor libraries from Releases and extract to
vendor/:tar -xzf vendor-libs.tar.gz -C vendor/
Or build from source (see Building Dependencies).
-
Generate Pi bundle
The Pi agent JavaScript bundle is not included in the repo. Generate it:
cd /path/to/pi-coding-agent bun run build:ios cp dist/pi-ios-bundle.js /path/to/pi-ios/app/Pi/Resources/ -
Generate Xcode project
cd app xcodegen generate -
Open in Xcode and build
open Pi.xcodeproj
Select your device and build (⌘B).
Pi requires an OpenRouter API key to access AI models. Create a config.json file in the app's Documents folder:
Option 1: Using devicectl (from Mac)
echo '{"openrouter_api_key": "sk-or-v1-your-key-here"}' > /tmp/config.json
xcrun devicectl device copy to \
--device YOUR_DEVICE_UDID \
--domain-type appDataContainer \
--domain-identifier com.dannote.pi \
--source /tmp/config.json \
--destination Documents/config.jsonOption 2: Using Files app (on iPhone)
- Open the Files app
- Navigate to "On My iPhone" → "Pi"
- Create a new file called
config.json - Add:
{"openrouter_api_key": "sk-or-v1-your-key-here"}
Pi requires three main dependencies to be built for iOS:
Build WebKit for iOS with C_LOOP interpreter enabled (required since JIT is not available on iOS):
cd ~/Development
git clone https://github.com/ArtSabintsev/WebKit.git
cd WebKit
mkdir build-ios-device && cd build-ios-device
cmake .. \
-G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_SYSTEM_NAME=iOS \
-DCMAKE_OSX_SYSROOT=iphoneos \
-DCMAKE_OSX_ARCHITECTURES=arm64 \
-DPORT=JSCOnly \
-DENABLE_STATIC_JSC=ON \
-DENABLE_JIT=OFF \
-DENABLE_C_LOOP=ON \
-DENABLE_WEBASSEMBLY=OFF \
-DENABLE_SAMPLING_PROFILER=OFF
ninja JavaScriptCoreBuild Bun for iOS using the iOS port:
git clone https://github.com/dannote/bun.git -b ios-port
cd bun
mkdir build/ios-device && cd build/ios-device
cmake ../.. \
-G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE=../../cmake/toolchains/ios-device.cmake
ninjaBuild Ghostty for iOS:
git clone https://github.com/dannote/ghostty.git -b ios-manual-backend
cd ghostty
zig build \
-Doptimize=ReleaseFast \
-Dtarget=aarch64-ios \
--build-file src/build.zig┌─────────────────────────────────────────────────────┐
│ Pi for iOS │
├─────────────────────────────────────────────────────┤
│ SwiftUI App │
│ ├─ TerminalView (UIView + UIKeyInput) │
│ ├─ KeyboardAccessory (iOS 26 Liquid Glass) │
│ └─ BunGhosttyBridge (pipes stdin/stdout) │
├─────────────────────────────────────────────────────┤
│ Ghostty Terminal (Metal GPU rendering) │
│ └─ Manual termio backend for iOS │
├─────────────────────────────────────────────────────┤
│ Bun Runtime (JSC with C_LOOP interpreter) │
│ ├─ iOS embedding API (bun_start, bun_eval) │
│ ├─ Stubs for iOS-unsupported features │
│ └─ Full npm package compatibility │
├─────────────────────────────────────────────────────┤
│ Pi Coding Agent (bundled JavaScript) │
│ └─ Interactive mode, tools, AI integration │
└─────────────────────────────────────────────────────┘
- Bun on iOS: First working port of Bun to iOS, using JSC's C_LOOP interpreter instead of JIT
- Ghostty on iOS: Manual termio backend for Ghostty's GPU-rendered terminal
- No Private APIs: App Store compliant - no JIT, no private frameworks
- Native Performance: ~600ms cold start, full npm package support
- No JIT: JavaScript runs in interpreter mode (~10x slower than JIT)
- No WebAssembly: Disabled due to JIT requirement
- No CPU Profiler: Sampling profiler requires JIT
- Memory: C_LOOP interpreter uses more memory than JIT
- pi-coding-agent - The pi coding agent
- Bun iOS Port - Bun runtime for iOS
- Ghostty iOS - Ghostty terminal for iOS
MIT License - see LICENSE for details.
Contributions welcome! Please read the contributing guidelines before submitting PRs.
