Skip to main content

Module app

Module app 

Source
Expand description

SwiftUI App lifecycle — pure Rust, no Swift compiler.

Constructs a SwiftUI App conformance at run time by building:

  1. A zero-size struct metadata (the “app type”)
  2. An App protocol witness table with body.getter
  3. A scene for that body to return — see crate::scene

Then calls App.main(), which enters the SwiftUI event loop.

§Example

use swiftui_native::{app, views};

app::run(|| views::text("Hello from pure Rust!"));

A whole app rather than one window:

use swiftui_native::{app, scene, views};

app::run_scene(|| scene::group(vec![
    scene::window_group(|| views::text("main")),
    scene::settings(|| views::text("preferences")),
]));

Functions§

run
Launch a SwiftUI app with a Rust-built root view. Never returns.
run_scene
Launch a SwiftUI app whose body is any scene. Never returns.