Skip to content

feat(ios): add UIKit RuneView shell, CADisplayLink pacing, and rune::run entry (#803) - #3239

Merged
Hona merged 1 commit into
devfrom
feat/ios-shell
Dec 2, 2026
Merged

Hona merged 1 commit into
devfrom
feat/ios-shell

Conversation

@Hona

@Hona Hona commented Dec 2, 2026

Copy link
Copy Markdown
Member

Summary

Adds the first M6 iOS shell slice so Rune apps start with rune::run / App::run on iOS or embed a RuneView (UIView + CAMetalLayer) inside UIKit / SwiftUI hosts.

  • iOS native shell (crates/rune/src/platform/ios/):
    • RuneView (UIView subclass whose +layerClass returns CAMetalLayer) driven by rune::embed::LayerHost and a main-run-loop CADisplayLink (requesting 120 Hz via CAFrameRateRange on iOS 15+).
    • Pure rune::machine lifecycle and pacing state machine (machine.rs) that pauses CADisplayLink at rest (0% CPU) and immediately pauses + cancels active touches when entering the background or detaching from a window so Metal never acquires drawables in the background.
    • Multi-touch UITouch forwarding (touch.rs), UIEdgeInsets -> Cx::safe_area() CSS-order mapping (insets.rs), Cx::keyboard_inset() hook, and UITraitCollection dark/light mode -> Cx::system_dark().
    • Standalone rune::run / App::run entry via UIApplicationMain + RuneIosAppDelegate (host.rs), plus rune::ios::view / rune::ios::view_app and rune_ios_view_* C FFI helpers (ffi.rs) for SwiftUI / UIKit embedding.
  • Shared Apple crate support:
    • Added rune_core::main_queue::on_main_after (dispatch_after_f) for timed wakes on macOS and iOS.
    • Shared Apple CoreFoundation collation (CFStringCompareWithOptionsAndLocale) and Apple system font fallback tables across macOS and iOS in rune-text, and exposed rune_gpu::with_layer / native on iOS.
    • Added LayerHost::from_core_animation_layer_configured (iOS) and LayerHost::attach_core_animation_layer (Apple) so App<S> configuration and Runtime<S> survive view re-attachment.
  • Example and docs: Added examples/ios-hello (with include/RuneView.h and SwiftUI UIViewRepresentable snippet), IOS.md, and a changelog entry.

Verification

  • cargo test -j 1 -p rune --lib ios: 23 passed, 0 failed (state machine, touch tracker, inset/scale/dark-mode conversions, Dynamic Type).
  • cargo test -j 1 -p ios-hello: 1 passed, 0 failed.
  • cargo check -j 1 -p rune --lib (Windows) and cargo check -j 1 -p rune --target wasm32-unknown-unknown: passed.
  • cargo check -j 1 --target aarch64-apple-ios -p rune --lib -p ios-hello (with temporary local blake3/pure override to bypass missing Apple xcrun on Windows, reverted before commit): 0 errors, 0 warnings.
  • scripts/file-size.sh: 0 errors, 0 new warnings.
  • Not run locally: live Xcode linking, iOS Simulator launch, and physical iPhone device testing were not run on this Windows host.

Fixes #803

Copilot AI balanced review requested due to automatic review settings December 2, 2026 04:39

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@Hona
Hona merged commit ca92ffe into dev Dec 2, 2026
6 of 7 checks passed
@Hona
Hona deleted the feat/ios-shell branch December 2, 2026 04:42
pascalandr added a commit to NeuralNomadsAI/rune that referenced this pull request Dec 2, 2026
…eyboard (anomalyco#803)

Slice 1 (anomalyco#3239) draws and takes touches, but a focused text field gets no
keyboard on iOS. A RuneView now carries a hidden RuneTextInput subview that
becomes first responder while a field (or an El::ime_cursor surface) takes
text and resigns when focus leaves it.

The keyboard edits a copy of the field (text/doc.rs): the runtime's ime_text
window plus marked text, in UTF-16 at the UIKit edge, so UIKit sees each edit
at once. Edits reach the runtime as Key::Text/Backspace/Enter and
Ime::Preedit/Commit/Select; after each frame the copy is reconciled with the
runtime and the input delegate hears when text or caret moved under it.
Passwords show the keyboard nothing and take commits as typed text.
text/traits.rs maps InputMode, single_line and secure to UIKeyboardType,
UIReturnKeyType, autocorrection and capitalization, and reloads an attached
keyboard when they change, after any composition ends. Geometry questions
answer with the field's caret rect; per-character geometry is a later slice.

keyboard.rs observes UIKeyboardWillChangeFrame/WillHide and turns the
keyboard's overlap of the view's bottom edge into Cx::keyboard_inset(), so a
standalone rune::run app no longer needs rune_ios_view_set_keyboard_inset.
The responder syncs after the view's RefCell is released, since taking or
giving up the keyboard can post those notifications synchronously.

focused_editable_input and commit_secure_text, used by Android, now compile
for iOS too. examples/ios-hello gains a note field (RUNE_IOS_HELLO_FOCUS=1
focuses it at launch).

Tests: host tests for the document, the traits and their reload, the
keyboard overlap, and TextState/apply against a real Runtime (typing,
composition, autocorrection, passwords, InputMode::None).

Co-authored-by: Abraham Gonzalez <[email protected]>
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.

iOS: an app starts with rune::run and draws in a RuneView (first slice of M6)

2 participants