Skip to content

Conversation

@alltheseas
Copy link

Summary

This PR adds iOS support to egui through a new egui-ios crate that provides Swift FFI bindings via swift-bridge.

New Crate: egui-ios

The egui-ios crate provides Swift-compatible types for embedding egui in iOS apps:

  • InputEvent - Touch, keyboard, and lifecycle events from Swift to egui
  • OutputState - Cursor, keyboard, and IME state from egui to Swift
  • CursorIcon - Cursor icons mapped to iOS equivalents

Features

  • Native text input support with IME/autocomplete
  • Scene lifecycle callbacks (background/inactive/active)
  • Virtual key handling (backspace, enter, arrows, etc.)
  • Keyboard visibility and IME rect tracking
  • Pre-generated Swift bindings included (no build step needed for Swift developers)

Minimum iOS Version: 13.0

Changes

  • Add egui-ios crate with Swift FFI bindings (369 lines of Rust)
  • Add xtask bundle-ios command for building iOS app bundles
  • Add iOS to eframe platform list in README
  • Add egui-ios to workspace members and changelog list

Files Added/Modified

File Change
crates/egui-ios/ New crate (12 files)
xtask/src/ios.rs New iOS bundling module
xtask/src/main.rs Add bundle-ios command
Cargo.toml Add egui-ios to workspace
README.md Add iOS to platform list
CHANGELOG.md Add egui-ios changelog link

Known Limitations

  • Clipboard: The arboard crate doesn't support iOS yet, so apps should implement clipboard via UIPasteboard in Swift
  • Safe area: Uses existing objc2 bridge in egui-winit (already upstream in 0.33.x)

Integration Example

A typical SwiftUI integration involves:

  1. Creating a MTKView for Metal rendering
  2. Forwarding touch events via InputEvent::from_* methods
  3. Running egui each frame and checking OutputState for keyboard/IME state
  4. Using a native UITextField overlay for text input with autocomplete/autocorrect

Test Plan

  • Builds for aarch64-apple-ios target
  • Builds for aarch64-apple-ios-sim target
  • cargo xtask bundle-ios creates valid .app bundle
  • Swift bindings compile in Xcode project

🤖 Generated with Claude Code

This PR adds iOS support to egui through a new `egui-ios` crate that provides
Swift FFI bindings via swift-bridge.

## New Crate: egui-ios

The `egui-ios` crate provides Swift-compatible types for embedding egui in iOS apps:

- `InputEvent` - Touch, keyboard, and lifecycle events from Swift to egui
- `OutputState` - Cursor, keyboard, and IME state from egui to Swift
- `CursorIcon` - Cursor icons mapped to iOS equivalents

### Features
- Native text input support with IME/autocomplete
- Scene lifecycle callbacks (background/inactive/active)
- Virtual key handling (backspace, enter, arrows, etc.)
- Keyboard visibility and IME rect tracking

### Minimum iOS Version: 13.0

## Changes

- Add `egui-ios` crate with Swift FFI bindings
- Add `xtask bundle-ios` command for building iOS app bundles
- Add iOS to eframe platform list in README
- Add egui-ios to workspace

## Known Limitations

- Clipboard: arboard doesn't support iOS yet, apps should implement via UIPasteboard
- Safe area: Uses objc2 bridge until winit 0.31+ adds native support

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@github-actions
Copy link

Preview is being built...

Preview will be available at https://egui-pr-preview.github.io/pr/7768-ios-support

View snapshot changes at kitdiff

@alltheseas
Copy link
Author

alltheseas commented Dec 12, 2025

⚠️ code not reviewed by a professional developer ⚠️

using this approach, managed to get egui notedeck running on iOS

https://github.com/alltheseas/notedeck-iOS/

image

@alltheseas
Copy link
Author

Received feedback from @jb55 on memory:

Memory Limits

iOS has stricter virtual memory limits than desktop. Key adjustments:

LMDB map size: Reduced from 1 TiB (desktop) to 1 GiB (iOS)
Location: crates/notedeck/src/app.rs
iOS kills apps that try to map too much virtual memory

on ios you can do 32GiB with extended virtual addressing entitlement

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant