Skip to main content

run

Function run 

Source
pub fn run<V: IntoView>(builder: impl Fn() -> V + 'static) -> !
Expand description

Launch a SwiftUI app with a Rust-built root view. Never returns.

A WindowGroup around whatever the builder returns, which is the shape of the shortest useful app. run_scene is the general form.

The body is anything that is a view — a View from the chainable DSL, a ViewHandle, or a &str — so the entry point does not end in a conversion the way it used to.

app::run(|| text("Hello!").padding(20.0));
Examples found in repository?
examples/app.rs (lines 10-28)
9fn main() {
10    run(|| {
11        vstack(&[
12            text("Hello from Rust! 🦀")
13                .padding(12.0)
14                .bg(Color::BLUE)
15                .rounded(8.0)
16                .opacity(0.95),
17            spacer(),
18            hstack(&[
19                image("star.fill"),
20                text("No Swift compiler needed"),
21            ]),
22            divider(),
23            text("Pure dlsym + arm64 asm → SwiftUI")
24                .padding(8.0),
25        ])
26        .padding(40.0)
27        .into_handle()
28    });
29}