macro_rules! ios_app {
($state_ty:ty, $build:expr $(,)?) => { ... };
($state_ty:ty, $state_init:expr, $build:expr $(,)?) => { ... };
}Expand description
Bind a generated app’s State/build to the fixed iOS C-ABI exports
(Makepad app_main! precedent).
Stamps out the twenty-four frust_* symbols the generated Swift app
declares
(the seven lifecycle/input exports, the three text-input exports —
frust_ime_apply, frust_ime_state_json, frust_string_free —
the four clipboard/system-edit-menu exports — frust_edit_command,
frust_take_clipboard_write, frust_take_paste_request and
frust_selection_toolbar_json, the route that keeps every paste exempt
from iOS’s paste-permission alert by going through the platform’s own
menu (see ffi_glue::edit_command) —
frust_set_appearance (the dark-mode export),
frust_set_reduce_motion (the reduced-motion accessibility export — the
same transport over a different sensor: UIAccessibility, not
UITraitCollection),
frust_on_deep_link (cold-start/running deep-link delivery),
frust_init_accessibility (the accesskit adapter
attach — the one export whose UIView pointer the CAMetalLayer-only
frust_init cannot supply), frust_set_insets (the
SafeArea inset delivery), frust_system_ui_state
(the system-UI override peek — see
ffi_glue::system_ui_state), plus frust_set_surface_mode and
frust_platform_view_commands_json (the
translucent-surface opt-in latch and command-backlog peek getter — see
ffi_glue::set_surface_mode/ffi_glue::platform_view_commands_json),
plus frust_set_present_sync and frust_present_frame (the
present-sync latch and its per-tick UI-thread present — see
ffi_glue::set_present_sync/ffi_glue::present_frame)),
each delegating to the non-generic runtime in
[ffi_glue]. frust_init constructs the app’s erased view tree and returns
an opaque handle; the rest operate on that handle. It also initializes the
process-wide
[frust_reactive::ReactiveRuntime] (idempotent, framework-side inside
[ffi_glue::init] rather than emitted here, so both arms below get it with
no macro duplication) before the state/view tree is constructed.
Unlike android_app!, this macro is
call-site transparent: it is invoked unconditionally in the generated
src/lib.rs, because every symbol it emits is itself
#[cfg(target_os = "ios")], so off-iOS the invocation expands to nothing:
frust::ios_app!(AppState, move |s| root.build(s));Two forms:
ios_app!($state_ty, $build)—$state_tymust implementDefault; the initial state is$state_ty::default().ios_app!($state_ty, $state_init, $build)—$state_initis aFnOnce() -> $state_tyfactory, for a state type that doesn’t implementDefault(e.g. one a futureComponent::initbuilds). The 2-arg form delegates to this one with<$state_ty as Default>::defaultas the factory.
$build is the root component’s build closure, a FnMut(&mut State) -> impl View<State> (move |s| root.build(s)).