Skip to content

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

Done

Description

@theabecaster

Why: PLAN.md puts iOS at M6, and embed::LayerHost already draws on a CAMetalLayer. Nothing drives it, so no Rune app runs on an iPhone unless the host writes its own view, display link and touch forwarding.

Ask: is the iOS shell wanted now, ahead of M5? A first slice is written and tested on a fork, as a reference to take, change or drop.

Today (0aa0837, from reading the code)

  • App::run has no iOS branch: it falls through to the winit path.
  • platform/ has no iOS folder, and display_link.rs is macOS only.
  • Nothing bundles, signs or installs an iOS build.

What the fork branch adds

  • platform/ios/: RuneView is a UIView on a CAMetalLayer over LayerHost, with the app's state type erased.
  • Pacing: a CADisplayLink asks for 120 Hz and is stepped by one rune::machine state machine. It rests when nothing moves and never runs in the background.
  • Input: one finger goes through Runtime::touch, and light and dark follow the trait collection.
  • Entry: rune::run and App::run start UIKit on iOS. rune::ios::view returns the view for a UIKit or SwiftUI host.
  • Packaging: scripts/ios-app stages a bundle, signs it, installs it and launches it. IOS.md documents the loop.
  • Changes to existing files: a cfg branch in App::try_run; one mod and one pub use line; main_queue.rs built for iOS with a timed variant; two cfg attributes so the desktop window::run isn't built for iOS; and a timeout parameter on mac_app_install.py's command, which the new script shares. No new dependencies: Cargo.lock is unchanged.

Checked

  • iPhone 18 Pro (iOS 27.0.1): examples/web-hello launches, draws, and its list scrolls under a finger.
  • Simulator (iOS 27.0): examples/hello and examples/web-hello draw, web-hello follows a light/dark switch, and it uses 0% CPU at rest.
  • 11 tests step the pacing machine, and 6 cover the script.

Not checked, and not there yet

  • Frame rate on the device was not measured, and the background pause was checked by the machine's tests only. rune::ios::view compiles but was not run in a SwiftUI host. Rotation is untested.
  • There is no soft keyboard, safe-area inset, second finger, VoiceOver or clipboard, and on_ready never runs.
  • LayerHost::frame still steps to Instant::now(), not the display link's target time.
  • Only the new tests were run, not the whole suite.

Proposed next slices, one issue each

  1. Safe-area and keyboard insets into Cx::safe_area.
  2. Frames timed to the display link's target, and the LayerHost fixes in GPU limits: a refused configure panics in LayerHost and on the web, an image past the device's largest texture is a validation error, and the Metal backend panics on macOS 11 and 12; fixes are on a fork #588.
  3. More than one finger.
  4. UITextInput on the existing Ime and ImeText seam.
  5. VoiceOver from the accessibility tree (iOS and Android: an app built on Rune can pass an independent WCAG 2.1 A and AA audit #110).

Branch: ios-shell of theabecaster/rune, two commits on dev 0aa0837.

Activity

  1. KAYOKG commented on Nov 18, 2026

    @KAYOKG

    We build desktop apps on Rune (pinned to 842c28c) and plan to ship a component library on top of it, so mobile matters to us. PLAN.md gives the order "macOS + Windows + Linux → web → iOS → Android", and this issue is the first iOS slice. Three questions, so we can design for it now:

    1. iOS: is this shell (or another) expected to land on dev, and is M6 still the target? If a tester helps, we can run the slice on our own devices and report back here.
    2. Android: is there a planned shape yet (a shell like platform/android/, InputConnection for text, an a11y backend as asked in iOS and Android: an app built on Rune can pass an independent WCAG 2.1 A and AA audit #110), or is it still open after iOS?
    3. Staying mobile-ready today: which APIs or patterns should app authors avoid so the same views run on iOS and Android later? For example window-only features (tray, multiple windows, global shortcuts), hover-only interactions, or anything that assumes a physical keyboard.

    A short answer is enough. A list in PLAN.md would help everyone building on Rune now.

  2. theabecaster commented on Nov 19, 2026

    @theabecaster
    Author

    Thanks! Testing: the ios-shell link is gone. The work is now on the ios branch of my fork, rebased on current dev. IOS.md covers running it on a simulator or device and what works so far. Any feedback on touch, the keyboard or frame rate is welcome here.

    Staying mobile-ready:

    • One window, sized by the screen. Lay out for any size and rotation.
    • No hover-only paths, and every keyboard shortcut also needs a touch path.
    • Secondary actions via Tx::popup_menu, not raw right-click. Long press opens the same menu.
    • Keep desktop-only crates (tray, global shortcuts, file dialogs) behind cfg.
    • Pad full-screen roots by Cx::safe_area, and keep touch targets around 44 pt or larger.
  3. opencodejr commented on Nov 25, 2026

    @opencodejr
    Contributor

    Thanks for the careful write-up, and for keeping this slice small.

    What I checked on current dev (a9d657f):

    • App::try_run in crates/rune/src/app.rs has a wasm variant and one for everything else, which goes to crate::window::run (unless --headless is passed). So iOS still ends up on the winit path.
    • crates/rune/src/platform/ has no ios/ folder, and scripts/ has only the macOS mac_app_bundle.py and mac_app_install.py.
    • PLAN.md §10 lists M6 as the iOS shell, UITextInput, RuneView for SwiftUI embedding and split-process dev mode. On "ahead of M5": §13 says the first experimental web target is already in (WEB.md, examples/web-hello), so the order shouldn't block this slice.

    I found no other issue asking for an iOS shell. #110, #588 and #48 are related and fit your proposed follow-ups. I'm taking this as a feature request for the first slice: RuneView over LayerHost, CADisplayLink pacing as a rune::machine state machine, one-finger touch, appearance, the rune::run/App::run entry, and the bundle/sign/install script. I'll use your ios branch as the reference.

    For anyone else reading: the ios-shell link in the description is gone; the current work is on the ios branch, rebased on dev. I haven't built or run it yet, so the device and simulator results above are yours, not reproduced here. Safe-area and keyboard insets, display-link frame timing, multi-touch, UITextInput and VoiceOver are better as their own issues, as you suggest.

  4. opencodejr commented on Nov 25, 2026

    @opencodejr
    Contributor

    I looked at taking the first slice into dev but didn't make a change.

    • It can't be checked here. The slice is a new UIKit shell: RuneView on a CAMetalLayer, CADisplayLink pacing, touch forwarding, an iOS branch in App::try_run, and the bundle/sign/install script. The environment I work in has no Rust toolchain and no iOS SDK or Xcode tools, so I couldn't build it or launch it on a simulator. Porting it without that would put untested platform code on dev, which apps pin.
    • The reference branch has grown. Your ios branch (head d5e50cf1) is now 66 commits and about 17.8k added lines across 254 files on top of dev. It goes well beyond the slice described here: Core Text emoji, .ipa distribution signing, privacy manifests, icons, a Swift package, ios-lib and a site page. I've only looked at its file list, not its code.

    If you'd like this to land, a pull request from your branch cut back to the first slice would be the easiest to review: the shell, pacing, one finger, appearance, the entry point and scripts/ios-app, with its tests, IOS.md and a changelog/unreleased/ entry. The rest can follow as the separate issues you proposed. Someone with a Mac will need to build and run it, and whether iOS work starts now is still up to the maintainers.

  5. pascalandr commented on Nov 30, 2026

    @pascalandr

    We did the Android slices with @Hona (#2647, #2697, #2699, #2700, #2724) and ship a Rune app on Android. We would like iOS next and can put time into it now.

    Offer: carry this issue's first slice onto current dev as one small reference branch (shell, pacing, one finger, appearance, the rune::run entry, the bundle script), then the follow-ups as one issue each, the way Android went. Each slice would be built and run on the iOS simulator in CI on our fork, with screenshots attached. Our device access is limited, so the simulator is the main check.

    Why re-slice: theabecaster:ios (d5e50cf) is 66 commits and about 17.8k added lines on a base from 19 November; a trial merge into today's dev gives 65 conflicts.

    Two questions before we start:

    1. @theabecaster: are you still working on this, and are you fine with us cutting the slices from your branch? Each issue would name your branch as where the code comes from. If you would rather cut the first slice yourself, we will test it instead.
    2. @Hona: is the iOS shell wanted on dev now, and would you take it the same way as Android (one issue per slice, with a reference branch)?
  6. theabecaster commented on Nov 30, 2026

    @theabecaster
    Author

    Yes, still on it, and happy for you to base the slices on my branch. Co-author credit works for me. Since your device access is limited, I can review each slice and test it on a physical device. Tag me on the slice issues or for anything iOS-specific in the branch.

  7. Hona commented on Dec 2, 2026

    @Hona
    Member

    Merged the first M6 iOS shell slice in PR #3239 (ca92ffe61).

    Design landed:

    • Added crates/rune/src/platform/ios/ with a UIView/CAMetalLayer-backed RuneView over rune::embed::LayerHost, paced by a main-run-loop CADisplayLink (requesting 120 Hz on iOS 15+) and driven by a pure rune::machine state machine that rests at 0% CPU when idle and pauses/cancels touches immediately on backgrounding or window detach.
    • Wired rune::run / App::run on iOS to launch UIApplicationMain with a full-screen UIWindow hosting RuneView, and exported rune::ios::view, rune::ios::view_app, and rune_ios_view_* C FFI lifecycle helpers for UIKit / SwiftUI embedding.
    • Forwarded multi-touch UITouch events, safeAreaInsets (UIEdgeInsets -> Rune Cx::safe_area()), Cx::keyboard_inset(), and UITraitCollection dark/light mode (Cx::system_dark()).
    • Shared Apple main_queue::on_main_after, rune-text CoreFoundation collation and Apple font fallback tables, and rune-gpu with_layer/native on iOS, plus added examples/ios-hello (with include/RuneView.h and SwiftUI snippet) and IOS.md.

    Verified vs not run on hardware:

    • Verified locally and in CI: 23 unit tests in rune (platform::ios state machine, touch tracker, inset/scale/dark-mode conversions, Dynamic Type), examples/ios-hello unit test, Windows/Linux/Android/WASM builds, scripts/file-size.sh, and cargo check --target aarch64-apple-ios -p rune --lib -p ios-hello (0 errors, 0 warnings).
    • Not run on Apple hardware: live Xcode linking, iOS Simulator launch, and physical iPhone device runs were not executed on this Windows host. Follow-up slices (UITextInput, VoiceOver, UIPasteboard, haptics, display-link target timestamp pacing) can proceed as separate issues — please reopen or file a follow-up if anything misbehaves on Simulator or device.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions