Build Android and iOS apps in Rust

Share one Rust app model across Android and iOS, build a touch-friendly field-work screen, and check both native hosts.
Android

What you will build

Reuse one product workflow on Android and iOS while respecting each device
Build a touch-friendly work-order screen
Share state across Android and iOS
Add mobile targets and launch Android and iOS builds
A technician should not have a different inspection record because they opened it on another kind of phone. The work order, its completion status and its saved note describe the job; Android and iOS provide different hosts for working with it.
We will keep those job facts in shared Rust and build the same Compose screen for both targets. A note remains a local draft until the technician chooses to retain it against the work order. Sharing that behaviour does not remove the need to check each platform's keyboard, available space and launch process.
Install the Fission CLI and scaffold the Android and iOS project:
cargo install cargo-fission
fission init harbour-mobile
cd harbour-mobile
cargo add serde_yaml
fission add-target android ios --project-dir .
Start from a new project (optional)

Project layout

harbour-mobile/
├── Cargo.toml                 # generated dependencies
├── fission.toml               # app identity, targets and capabilities
├── src/
│   ├── main.rs                 # generated shared app entrypoint
│   ├── lib.rs                  # shared app setup
│   ├── app.rs                  # the Fission component shown in this tutorial
│   ├── state.rs              # the work order and its saved note
│   └── translations.rs
├── i18n/
│   ├── en-US.yaml
│   └── es-ES.yaml
├── platforms/
│   ├── android/
│   └── ios/
└── tests/                      # project-specific flow checks
fission init generates Cargo.toml, fission.toml, src/main.rs, src/lib.rs and src/app.rs. Add the task modules in the tree as you build the feature. Keep data shared across routes in GlobalState, and keep retained interaction such as a disclosure or draft field in the owning fission_component!. Request database, filesystem, network and session work through a reducer effect, job or service; never run host work while a component view is being built.
preview/lib.rs compiles the complete src/app.rs into WebAssembly so you can try the shared screen here. It does not emulate Android or iOS. Use the target-specific steps below to check native launch and interaction.
The preview seeds one work order in preview/lib.rs. MobileTaskState::default() stays empty; demo data does not become a production default.
Replace the generated src/lib.rs with the launcher below. Without that change, the normal target command would still run the scaffold's counter. The normal app starts with a form for entering an existing handover. It stores that record in memory on this installation; it does not authenticate a dispatcher or synchronise devices. The preview supplies one sample record so the later controls are immediately visible.
Keep user-facing labels in checked-in English and Spanish bundles. The launchers install both bundles and explicitly start in English. Selecting a supported device locale or adding an in-app language choice is a separate step; do not claim this example detects it automatically. The work-order details are supplied by the person entering the handover, so they are app data rather than translated interface labels. This example records an operator's status, not evidence that equipment is safe to use.

Run the finished example

fission run --target android --project-dir .

1. Build a touch-friendly work-order screen

Start with the work a technician actually needs to do: identify the site, equipment and due time before touching the inspection. The app state owns the work order, so the same screen and data model are used by both native targets.
{"id":"fission-tabs-1","tabs":[{"index":0,"label":"src/assignment.rs","value":"src-assignment-rs"},{"index":1,"label":"src/app.rs","value":"src-app-rs"},{"index":2,"label":"src/state.rs","value":"src-state-rs"},{"index":3,"label":"src/translations.rs","value":"src-translations-rs"},{"index":4,"label":"src/lib.rs","value":"src-lib-rs"},{"index":5,"label":"i18n/en-US.yaml","value":"i18n-en-us-yaml"},{"index":6,"label":"i18n/es-ES.yaml","value":"i18n-es-es-yaml"},{"index":7,"label":"preview/lib.rs","value":"preview-lib-rs"}]}
{"id":"fission-tabs-1","index":0,"label":"src/assignment.rs","value":"src-assignment-rs"}
use crate::state::{InspectionTask, MobileTaskState};
use fission::prelude::*;

pub fn valid_details(values: [&str; 6]) -> bool {
    values.iter().all(|value| !value.trim().is_empty() && value.chars().count() <= 500)
}

fission_component! {
    pub AssignmentForm<MobileTaskState> {
        state {
            reference: String = String::new(),
            title: String = String::new(),
            site: String = String::new(),
            equipment: String = String::new(),
            due: String = String::new(),
            instructions: String = String::new(),
        }
    }
    view(form, state, cx) {
        let tokens = &cx.view.env().theme.tokens;
        let ready = valid_details([&form.reference, &form.title, &form.site,
            &form.equipment, &form.due, &form.instructions]);
    } =>
    Column(gap: tokens.spacing.m, children: [
        Text(cx.tr("load.explanation")),
        FormControl(label: cx.tr("load.reference"), required: true, child:
            TextInput(bind: form.reference, semantics_identifier: "work.load.reference".to_string())),
        FormControl(label: cx.tr("load.title"), required: true, child:
            TextInput(bind: form.title, semantics_identifier: "work.load.title".to_string())),
        FormControl(label: cx.tr("load.site"), required: true, child:
            TextInput(bind: form.site, semantics_identifier: "work.load.site".to_string())),
        FormControl(label: cx.tr("load.equipment"), required: true, child:
            TextInput(bind: form.equipment, semantics_identifier: "work.load.equipment".to_string())),
        FormControl(label: cx.tr("load.due"), required: true, child:
            TextInput(bind: form.due, semantics_identifier: "work.load.due".to_string())),
        FormControl(label: cx.tr("load.instructions"), required: true, child:
            TextInput(bind: form.instructions, semantics_identifier: "work.load.instructions".to_string())),
        Button(child: Text(cx.tr("load.action")), key: "load-work-order",
            disabled: !ready,
            on_press: reduce {
                if state.task.is_none() && valid_details([&form.reference, &form.title,
                    &form.site, &form.equipment, &form.due, &form.instructions]) {
                    state.task = Some(InspectionTask {
                        reference: form.reference.trim().to_owned(),
                        title: form.title.trim().to_owned(),
                        site: form.site.trim().to_owned(),
                        equipment: form.equipment.trim().to_owned(),
                        due: form.due.trim().to_owned(),
                        instructions: form.instructions.trim().to_owned(),
                        complete: false, latest_note: None,
                    });
                }
            }).semantics_identifier("work.load.confirm"),
    ])
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn a_handover_needs_every_detail_and_bounded_text() {
        assert!(valid_details(["WO-7", "Inspect fan", "Workshop", "Fan 2", "Today", "Check cover"]));
        assert!(!valid_details(["WO-7", "", "Workshop", "Fan 2", "Today", "Check cover"]));
        let too_long = "a".repeat(501);
        assert!(!valid_details([&too_long, "Inspect fan", "Workshop", "Fan 2", "Today", "Check cover"]));
    }
}
{"id":"fission-tabs-1","index":1,"label":"src/app.rs","value":"src-app-rs"}
use crate::state::*;
use crate::assignment::AssignmentForm;
use fission::prelude::*;

fission_component! {
    pub MobileTaskPlanner<MobileTaskState>
    view(_planner, state, cx) {
        let tokens = &cx.view.env().theme.tokens;
        let shift_status = match &state.task {
            Some(task) if task.complete => cx.tr("shift.no_due"),
            Some(_) => cx.tr("shift.one_due"),
            None => cx.tr("shift.no_work"),
        };
    } =>
    Container(SafeArea(
        child: Scroll(
            direction: FlexDirection::Column,
            show_scrollbar: true,
            flex_grow: 1.0,
            child: Container(
                SemanticsRegion(
                    identifier: Some("mobile-field-work".to_string()),
                    label: Some(cx.tr("work.screen_label")),
                    child: Column(gap: tokens.spacing.l, children: [
                        Row(gap: tokens.spacing.m, align_items: ir_op::AlignItems::Center, children: [
                            Column(gap: tokens.spacing.xs, children: [
                                Text(cx.tr("shift.team"))
                                    .weight(tokens.typography.font_weight_bold),
                                Text(cx.tr("shift.morning"))
                                    .color(tokens.colors.text_secondary),
                            ]),
                            Spacer(flex_grow: 1.0),
                            Badge(text: shift_status),
                        ]),
                        match &state.task {
                            Some(task) => Container(Column(gap: tokens.spacing.m, children: [
                                Row(gap: tokens.spacing.s, wrap: ir_op::FlexWrap::Wrap, children: [
                                    Text(task.reference.clone())
                                        .weight(tokens.typography.font_weight_semibold),
                                    Badge(text: if task.complete {
                                        cx.tr("work.complete")
                                    } else {
                                        format!("{} {}", cx.tr("work.due"), task.due)
                                    }),
                                ]),
                                Text(task.title.clone())
                                    .size(tokens.typography.heading2_size)
                                    .weight(tokens.typography.font_weight_bold),
                                Text(format!("{} · {}", task.site, task.equipment))
                                    .color(tokens.colors.text_secondary),
                                Text(task.instructions.clone()),
                            ]))
                                .padding_all(tokens.spacing.l)
                                .bg(tokens.colors.surface)
                                .border(tokens.colors.border, 1.0)
                                .border_radius(tokens.radii.large),
                            None => AssignmentForm(),
                        },
                    ]),
                ),
            )
                .padding_all(tokens.spacing.l),
        )
    ))
    .height_length(Length::vh(100.0))
    .bg(tokens.colors.background)
}
{"id":"fission-tabs-1","index":2,"label":"src/state.rs","value":"src-state-rs"}
use fission::prelude::*;

#[derive(Clone, Debug, PartialEq, Eq)]
pub struct InspectionTask {
    pub reference: String,
    pub title: String,
    pub site: String,
    pub equipment: String,
    pub due: String,
    pub instructions: String,
    pub complete: bool,
    pub latest_note: Option<String>,
}

#[derive(Clone, Debug, Default, PartialEq, Eq)]
pub struct MobileTaskState {
    pub task: Option<InspectionTask>,
}

impl GlobalState for MobileTaskState {}
{"id":"fission-tabs-1","index":3,"label":"src/translations.rs","value":"src-translations-rs"}
use std::collections::HashMap;

use fission::i18n::{Locale, TranslationBundle};
use fission::prelude::*;

pub fn create_env(locale: &str) -> Env {
    let mut env = Env::default();
    env.locale = Locale::from(locale);
    for (bundle_locale, source) in [
        ("en-US", include_str!("../i18n/en-US.yaml")),
        ("es-ES", include_str!("../i18n/es-ES.yaml")),
    ] {
        let messages: HashMap<String, String> =
            serde_yaml::from_str(source).expect("valid work-order translations");
        env.i18n.add_bundle(TranslationBundle {
            locale: Locale::from(bundle_locale),
            messages,
        });
    }
    env
}
{"id":"fission-tabs-1","index":4,"label":"src/lib.rs","value":"src-lib-rs"}
mod app;
mod assignment;
mod state;
mod translations;

use fission::prelude::*;

#[cfg(not(any(target_arch = "wasm32", target_os = "android", target_os = "ios")))]
pub fn run_desktop() -> anyhow::Result<()> {
    DesktopApp::<state::MobileTaskState, _>::new(app::MobileTaskPlanner)
        .with_env(translations::create_env("en-US"))
        .run()
}

#[cfg(any(target_os = "android", target_os = "ios"))]
fn mobile_app() -> MobileApp<state::MobileTaskState, app::MobileTaskPlanner> {
    let app = MobileApp::<state::MobileTaskState, _>::new(app::MobileTaskPlanner)
        .with_env(translations::create_env("en-US"))
        .with_title("Field work");
    #[cfg(target_os = "android")]
    let app = app.with_test_control_port(48761);
    app
}

#[cfg(any(target_os = "android", target_os = "ios"))]
pub fn run_mobile() -> anyhow::Result<()> { mobile_app().run() }

#[cfg(target_os = "android")]
#[no_mangle]
fn android_main(app_handle: AndroidApp) {
    let _ = mobile_app().run_with_android_app(app_handle);
}

#[cfg(target_arch = "wasm32")]
#[wasm_bindgen::prelude::wasm_bindgen(start)]
pub fn run_web() -> Result<(), wasm_bindgen::JsValue> {
    console_error_panic_hook::set_once();
    WebApp::<state::MobileTaskState, _>::new(app::MobileTaskPlanner)
        .with_env(translations::create_env("en-US"))
        .with_title("Field work")
        .run()
        .map_err(|error| wasm_bindgen::JsValue::from_str(&error.to_string()))
}
{"id":"fission-tabs-1","index":5,"label":"i18n/en-US.yaml","value":"i18n-en-us-yaml"}
shift.team: "Northbank Field Team"
shift.morning: "Today · Morning shift"
shift.one_due: "1 due"
shift.no_due: "0 due"
shift.no_work: "No work"
work.screen_label: "Field work for today"
work.complete: "Complete"
work.due: "Due"
work.empty.title: "No work orders are assigned to this shift."
work.empty.body: "When a dispatcher assigns work, it will appear here."
work.action.complete: "Mark inspection complete"
work.action.reopen: "Reopen inspection"
work.note.label: "Shift note"
work.note.placeholder: "Record a reading or handover detail"
work.note.save: "Save note"
work.note.saved: "Saved shift note"
load.explanation: "Enter the details of an existing handover. Each field is required and limited to 500 characters. This stores one local working record, not a dispatcher assignment."
load.reference: "Work-order reference"
load.title: "Task"
load.site: "Site"
load.equipment: "Equipment"
load.due: "Due-time description"
load.instructions: "Instructions"
load.action: "Open this handover"
{"id":"fission-tabs-1","index":6,"label":"i18n/es-ES.yaml","value":"i18n-es-es-yaml"}
shift.team: "Equipo de campo de Northbank"
shift.morning: "Hoy · Turno de mañana"
shift.one_due: "1 pendiente"
shift.no_due: "0 pendientes"
shift.no_work: "Sin trabajo"
work.screen_label: "Trabajo de campo de hoy"
work.complete: "Completada"
work.due: "Vence"
work.empty.title: "No hay órdenes de trabajo asignadas a este turno."
work.empty.body: "Las órdenes aparecerán aquí cuando las asigne un supervisor."
work.action.complete: "Completar inspección"
work.action.reopen: "Reabrir inspección"
work.note.label: "Nota del turno"
work.note.placeholder: "Anota una lectura o un detalle para el relevo"
work.note.save: "Guardar nota"
work.note.saved: "Nota del turno guardada"
load.explanation: "Introduce un relevo existente. Todos los campos son obligatorios y admiten hasta 500 caracteres. Solo se guarda un registro local, no una asignación autenticada."
load.reference: "Referencia de trabajo"
load.title: "Tarea"
load.site: "Ubicación"
load.equipment: "Equipo"
load.due: "Plazo descrito"
load.instructions: "Instrucciones"
load.action: "Abrir este relevo"
{"id":"fission-tabs-1","index":7,"label":"preview/lib.rs","value":"preview-lib-rs"}
mod app;
mod assignment;
mod state;
mod translations;

use fission::prelude::*;
use wasm_bindgen::prelude::*;

#[wasm_bindgen(start)]
pub fn run() -> Result<(), JsValue> {
    console_error_panic_hook::set_once();
    WebApp::<state::MobileTaskState, _>::new(app::MobileTaskPlanner)
        .with_env(translations::create_env("en-US"))
        .with_state_init(|state| {
            state.task = Some(state::InspectionTask {
                reference: "WO-1048".to_string(),
                title: "Cold-room compressor inspection".to_string(),
                site: "Northbank Food Hub".to_string(),
                equipment: "CMP-7A-2219".to_string(),
                due: "10:30".to_string(),
                instructions: "Check the alarm panel and record the pressure reading before the morning delivery arrives.".to_string(),
                complete: false,
                latest_note: None,
            });
        })
        .with_title("Build Android and iOS apps in Rust")
        .mount("#fission-web-mount")
        .run()
        .map_err(|error| JsValue::from_str(&error.to_string()))
}
{"id":"fission-tabs-1"}
Build a touch-friendly work-order screen: Confirm the order reference, location, equipment, due time and inspection instructions are visible before taking action.
Show the app preview
Hide the app preview

2. Share state across Android and iOS

Use shared state and component modules for the product workflow. Give touch targets comfortable space, make the main action reachable without precise gestures, and keep labels visible when a control is selected. Check the same route or screen with long translated text.
The work order is shared application data, so changing its status updates GlobalState. The inline reducer stays beside the action here because this tutorial uses it only once; a transition shared by several screens should be a named reducer.
{"id":"fission-tabs-1","tabs":[{"index":0,"label":"src/app.rs","value":"src-app-rs"},{"index":1,"label":"src/state.rs","value":"src-state-rs"},{"index":2,"label":"src/translations.rs","value":"src-translations-rs"},{"index":3,"label":"src/lib.rs","value":"src-lib-rs"},{"index":4,"label":"preview/lib.rs","value":"preview-lib-rs"}]}
{"id":"fission-tabs-1","index":0,"label":"src/app.rs","value":"src-app-rs"}
use crate::state::*;
use crate::assignment::AssignmentForm;
use fission::prelude::*;

fission_component! {
    pub MobileTaskPlanner<MobileTaskState>
    view(_planner, state, cx) {
        let tokens = &cx.view.env().theme.tokens;
        let shift_status = match &state.task {
            Some(task) if task.complete => cx.tr("shift.no_due"),
            Some(_) => cx.tr("shift.one_due"),
            None => cx.tr("shift.no_work"),
        };
    } =>
    Container(SafeArea(
        child: Scroll(
            direction: FlexDirection::Column,
            show_scrollbar: true,
            flex_grow: 1.0,
            child: Container(
                SemanticsRegion(
                    identifier: Some("mobile-field-work".to_string()),
                    label: Some(cx.tr("work.screen_label")),
                    child: Column(gap: tokens.spacing.l, children: [
                        Row(gap: tokens.spacing.m, align_items: ir_op::AlignItems::Center, children: [
                            Column(gap: tokens.spacing.xs, children: [
                                Text(cx.tr("shift.team"))
                                    .weight(tokens.typography.font_weight_bold),
                                Text(cx.tr("shift.morning"))
                                    .color(tokens.colors.text_secondary),
                            ]),
                            Spacer(flex_grow: 1.0),
                            Badge(text: shift_status),
                        ]),
                        match &state.task {
                            Some(task) => Container(Column(gap: tokens.spacing.m, children: [
                                Row(gap: tokens.spacing.s, wrap: ir_op::FlexWrap::Wrap, children: [
                                    Text(task.reference.clone())
                                        .weight(tokens.typography.font_weight_semibold),
                                    Badge(text: if task.complete {
                                        cx.tr("work.complete")
                                    } else {
                                        format!("{} {}", cx.tr("work.due"), task.due)
                                    }),
                                ]),
                                Text(task.title.clone())
                                    .size(tokens.typography.heading2_size)
                                    .weight(tokens.typography.font_weight_bold),
                                Text(format!("{} · {}", task.site, task.equipment))
                                    .color(tokens.colors.text_secondary),
                                Text(task.instructions.clone()),
                                Button(
                                    child: Text(if task.complete {
                                        cx.tr("work.action.reopen")
                                    } else {
                                        cx.tr("work.action.complete")
                                    }),
                                    key: "toggle-inspection",
                                    on_press: reduce {
                                        if let Some(task) = state.task.as_mut() {
                                            task.complete = !task.complete;
                                        }
                                    },
                                )
                                .semantics_identifier("mobile-work-order.complete".to_string()),
                            ]))
                                .padding_all(tokens.spacing.l)
                                .bg(tokens.colors.surface)
                                .border(tokens.colors.border, 1.0)
                                .border_radius(tokens.radii.large),
                            None => AssignmentForm(),
                        },
                    ]),
                ),
            )
                .padding_all(tokens.spacing.l),
        ),
    ))
    .height_length(Length::vh(100.0))
    .bg(tokens.colors.background)
}
{"id":"fission-tabs-1","index":1,"label":"src/state.rs","value":"src-state-rs"}
use fission::prelude::*;

#[derive(Clone, Debug, PartialEq, Eq)]
pub struct InspectionTask {
    pub reference: String,
    pub title: String,
    pub site: String,
    pub equipment: String,
    pub due: String,
    pub instructions: String,
    pub complete: bool,
    pub latest_note: Option<String>,
}

#[derive(Clone, Debug, Default, PartialEq, Eq)]
pub struct MobileTaskState {
    pub task: Option<InspectionTask>,
}

impl GlobalState for MobileTaskState {}
{"id":"fission-tabs-1","index":2,"label":"src/translations.rs","value":"src-translations-rs"}
use std::collections::HashMap;

use fission::i18n::{Locale, TranslationBundle};
use fission::prelude::*;

pub fn create_env(locale: &str) -> Env {
    let mut env = Env::default();
    env.locale = Locale::from(locale);
    for (bundle_locale, source) in [
        ("en-US", include_str!("../i18n/en-US.yaml")),
        ("es-ES", include_str!("../i18n/es-ES.yaml")),
    ] {
        let messages: HashMap<String, String> =
            serde_yaml::from_str(source).expect("valid work-order translations");
        env.i18n.add_bundle(TranslationBundle {
            locale: Locale::from(bundle_locale),
            messages,
        });
    }
    env
}
{"id":"fission-tabs-1","index":3,"label":"src/lib.rs","value":"src-lib-rs"}
mod app;
mod assignment;
mod state;
mod translations;

use fission::prelude::*;

#[cfg(not(any(target_arch = "wasm32", target_os = "android", target_os = "ios")))]
pub fn run_desktop() -> anyhow::Result<()> {
    DesktopApp::<state::MobileTaskState, _>::new(app::MobileTaskPlanner)
        .with_env(translations::create_env("en-US"))
        .run()
}

#[cfg(any(target_os = "android", target_os = "ios"))]
fn mobile_app() -> MobileApp<state::MobileTaskState, app::MobileTaskPlanner> {
    let app = MobileApp::<state::MobileTaskState, _>::new(app::MobileTaskPlanner)
        .with_env(translations::create_env("en-US"))
        .with_title("Field work");
    #[cfg(target_os = "android")]
    let app = app.with_test_control_port(48761);
    app
}

#[cfg(any(target_os = "android", target_os = "ios"))]
pub fn run_mobile() -> anyhow::Result<()> { mobile_app().run() }

#[cfg(target_os = "android")]
#[no_mangle]
fn android_main(app_handle: AndroidApp) {
    let _ = mobile_app().run_with_android_app(app_handle);
}

#[cfg(target_arch = "wasm32")]
#[wasm_bindgen::prelude::wasm_bindgen(start)]
pub fn run_web() -> Result<(), wasm_bindgen::JsValue> {
    console_error_panic_hook::set_once();
    WebApp::<state::MobileTaskState, _>::new(app::MobileTaskPlanner)
        .with_env(translations::create_env("en-US"))
        .with_title("Field work")
        .run()
        .map_err(|error| wasm_bindgen::JsValue::from_str(&error.to_string()))
}
{"id":"fission-tabs-1","index":4,"label":"preview/lib.rs","value":"preview-lib-rs"}
mod app;
mod assignment;
mod state;
mod translations;

use fission::prelude::*;
use wasm_bindgen::prelude::*;

#[wasm_bindgen(start)]
pub fn run() -> Result<(), JsValue> {
    console_error_panic_hook::set_once();
    WebApp::<state::MobileTaskState, _>::new(app::MobileTaskPlanner)
        .with_env(translations::create_env("en-US"))
        .with_state_init(|state| {
            state.task = Some(state::InspectionTask {
                reference: "WO-1048".to_string(),
                title: "Cold-room compressor inspection".to_string(),
                site: "Northbank Food Hub".to_string(),
                equipment: "CMP-7A-2219".to_string(),
                due: "10:30".to_string(),
                instructions: "Check the alarm panel and record the pressure reading before the morning delivery arrives.".to_string(),
                complete: false,
                latest_note: None,
            });
        })
        .with_title("Build Android and iOS apps in Rust")
        .mount("#fission-web-mount")
        .run()
        .map_err(|error| JsValue::from_str(&error.to_string()))
}
{"id":"fission-tabs-1"}
Share state across Android and iOS: Mark the inspection complete and confirm the status and action label change together.
Show the app preview
Hide the app preview

3. Keep an unsent note local and save it to shared state

A saved note belongs to the work order, not to an unrelated app-wide “latest note” value. Store it inside that record. Saving below moves the non-empty draft into shared memory and clears the editor only after the record is updated; it does not write to disk or send a report.
The note draft belongs to this editor, so keep it in the component's retained state. Once the technician saves it, it becomes work-order data in GlobalState and both Android and iOS render the same result. The preview shows that state transition without pretending to save to a server or device.
{"id":"fission-tabs-1","tabs":[{"index":0,"label":"src/app.rs","value":"src-app-rs"},{"index":1,"label":"src/state.rs","value":"src-state-rs"},{"index":2,"label":"src/translations.rs","value":"src-translations-rs"},{"index":3,"label":"src/lib.rs","value":"src-lib-rs"},{"index":4,"label":"preview/lib.rs","value":"preview-lib-rs"}]}
{"id":"fission-tabs-1","index":0,"label":"src/app.rs","value":"src-app-rs"}
use crate::state::*;
use crate::assignment::AssignmentForm;
use fission::prelude::*;

fission_component! {
    pub MobileTaskPlanner<MobileTaskState> {
        state {
            note_draft: String = String::new(),
        }
    }
    view(planner, state, cx) {
        let tokens = &cx.view.env().theme.tokens;
        let shift_status = match &state.task {
            Some(task) if task.complete => cx.tr("shift.no_due"),
            Some(_) => cx.tr("shift.one_due"),
            None => cx.tr("shift.no_work"),
        };
    } =>
    Container(SafeArea(
        child: Scroll(
            direction: FlexDirection::Column,
            show_scrollbar: true,
            flex_grow: 1.0,
            child: Container(
                SemanticsRegion(
                    identifier: Some("mobile-field-work".to_string()),
                    label: Some(cx.tr("work.screen_label")),
                    child: Column(gap: tokens.spacing.l, children: [
                        Row(gap: tokens.spacing.m, align_items: ir_op::AlignItems::Center, children: [
                            Column(gap: tokens.spacing.xs, children: [
                                Text(cx.tr("shift.team"))
                                    .weight(tokens.typography.font_weight_bold),
                                Text(cx.tr("shift.morning"))
                                    .color(tokens.colors.text_secondary),
                            ]),
                            Spacer(flex_grow: 1.0),
                            Badge(text: shift_status),
                        ]),
                        match &state.task {
                            Some(task) => Container(Column(gap: tokens.spacing.m, children: [
                                Row(gap: tokens.spacing.s, wrap: ir_op::FlexWrap::Wrap, children: [
                                    Text(task.reference.clone())
                                        .weight(tokens.typography.font_weight_semibold),
                                    Badge(text: if task.complete {
                                        cx.tr("work.complete")
                                    } else {
                                        format!("{} {}", cx.tr("work.due"), task.due)
                                    }),
                                ]),
                                Text(task.title.clone())
                                    .size(tokens.typography.heading2_size)
                                    .weight(tokens.typography.font_weight_bold),
                                Text(format!("{} · {}", task.site, task.equipment))
                                    .color(tokens.colors.text_secondary),
                                Text(task.instructions.clone()),
                                Button(
                                    child: Text(if task.complete {
                                        cx.tr("work.action.reopen")
                                    } else {
                                        cx.tr("work.action.complete")
                                    }),
                                    key: "toggle-inspection",
                                    on_press: reduce {
                                        if let Some(task) = state.task.as_mut() {
                                            task.complete = !task.complete;
                                        }
                                    },
                                )
                                .semantics_identifier("mobile-work-order.complete".to_string()),
                                TextInput(
                                    label: Some(cx.tr("work.note.label").into()),
                                    placeholder: Some(cx.tr("work.note.placeholder").into()),
                                    multiline: true,
                                    bind: planner.note_draft,
                                    semantics_identifier: "mobile-work-order.note-draft".to_string(),
                                ),
                                Button(
                                    child: Text(cx.tr("work.note.save")),
                                    key: "save-shift-note",
                                    disabled: planner.note_draft.trim().is_empty() || planner.note_draft.chars().count() > 2000,
                                    on_press: reduce {
                                        let note = planner.note_draft.trim().to_string();
                                        if !note.is_empty() && note.chars().count() <= 2000 {
                                            if let Some(task) = state.task.as_mut() {
                                                task.latest_note = Some(note);
                                                planner.note_draft.clear();
                                            }
                                        }
                                    },
                                )
                                .semantics_identifier("mobile-work-order.save-note".to_string()),
                                if let Some(note) = &task.latest_note {
                                    SemanticsRegion(
                                        identifier: Some("mobile-work-order.latest-note".to_string()),
                                        label: Some(cx.tr("work.note.saved")),
                                        child: Container(Column(gap: tokens.spacing.xs, children: [
                                            Text(cx.tr("work.note.label"))
                                                .weight(tokens.typography.font_weight_semibold),
                                            Text(note.clone()),
                                        ]))
                                            .padding_all(tokens.spacing.m)
                                            .bg(tokens.colors.background)
                                            .border(tokens.colors.border, 1.0)
                                            .border_radius(tokens.radii.medium),
                                    )
                                },
                            ]))
                                .padding_all(tokens.spacing.l)
                                .bg(tokens.colors.surface)
                                .border(tokens.colors.border, 1.0)
                                .border_radius(tokens.radii.large),
                            None => AssignmentForm(),
                        },
                    ]),
                ),
            )
                .padding_all(tokens.spacing.l),
        ),
    ))
    .height_length(Length::vh(100.0))
    .bg(tokens.colors.background)
}
{"id":"fission-tabs-1","index":1,"label":"src/state.rs","value":"src-state-rs"}
use fission::prelude::*;

#[derive(Clone, Debug, PartialEq, Eq)]
pub struct InspectionTask {
    pub reference: String,
    pub title: String,
    pub site: String,
    pub equipment: String,
    pub due: String,
    pub instructions: String,
    pub complete: bool,
    pub latest_note: Option<String>,
}

#[derive(Clone, Debug, Default, PartialEq, Eq)]
pub struct MobileTaskState {
    pub task: Option<InspectionTask>,
}

impl GlobalState for MobileTaskState {}
{"id":"fission-tabs-1","index":2,"label":"src/translations.rs","value":"src-translations-rs"}
use std::collections::HashMap;

use fission::i18n::{Locale, TranslationBundle};
use fission::prelude::*;

pub fn create_env(locale: &str) -> Env {
    let mut env = Env::default();
    env.locale = Locale::from(locale);
    for (bundle_locale, source) in [
        ("en-US", include_str!("../i18n/en-US.yaml")),
        ("es-ES", include_str!("../i18n/es-ES.yaml")),
    ] {
        let messages: HashMap<String, String> =
            serde_yaml::from_str(source).expect("valid work-order translations");
        env.i18n.add_bundle(TranslationBundle {
            locale: Locale::from(bundle_locale),
            messages,
        });
    }
    env
}
{"id":"fission-tabs-1","index":3,"label":"src/lib.rs","value":"src-lib-rs"}
mod app;
mod assignment;
mod state;
mod translations;

use fission::prelude::*;

#[cfg(not(any(target_arch = "wasm32", target_os = "android", target_os = "ios")))]
pub fn run_desktop() -> anyhow::Result<()> {
    DesktopApp::<state::MobileTaskState, _>::new(app::MobileTaskPlanner)
        .with_env(translations::create_env("en-US"))
        .run()
}

#[cfg(any(target_os = "android", target_os = "ios"))]
fn mobile_app() -> MobileApp<state::MobileTaskState, app::MobileTaskPlanner> {
    let app = MobileApp::<state::MobileTaskState, _>::new(app::MobileTaskPlanner)
        .with_env(translations::create_env("en-US"))
        .with_title("Field work");
    #[cfg(target_os = "android")]
    let app = app.with_test_control_port(48761);
    app
}

#[cfg(any(target_os = "android", target_os = "ios"))]
pub fn run_mobile() -> anyhow::Result<()> { mobile_app().run() }

#[cfg(target_os = "android")]
#[no_mangle]
fn android_main(app_handle: AndroidApp) {
    let _ = mobile_app().run_with_android_app(app_handle);
}

#[cfg(target_arch = "wasm32")]
#[wasm_bindgen::prelude::wasm_bindgen(start)]
pub fn run_web() -> Result<(), wasm_bindgen::JsValue> {
    console_error_panic_hook::set_once();
    WebApp::<state::MobileTaskState, _>::new(app::MobileTaskPlanner)
        .with_env(translations::create_env("en-US"))
        .with_title("Field work")
        .run()
        .map_err(|error| wasm_bindgen::JsValue::from_str(&error.to_string()))
}
{"id":"fission-tabs-1","index":4,"label":"preview/lib.rs","value":"preview-lib-rs"}
mod app;
mod assignment;
mod state;
mod translations;

use fission::prelude::*;
use wasm_bindgen::prelude::*;

#[wasm_bindgen(start)]
pub fn run() -> Result<(), JsValue> {
    console_error_panic_hook::set_once();
    WebApp::<state::MobileTaskState, _>::new(app::MobileTaskPlanner)
        .with_env(translations::create_env("en-US"))
        .with_state_init(|state| {
            state.task = Some(state::InspectionTask {
                reference: "WO-1048".to_string(),
                title: "Cold-room compressor inspection".to_string(),
                site: "Northbank Food Hub".to_string(),
                equipment: "CMP-7A-2219".to_string(),
                due: "10:30".to_string(),
                instructions: "Check the alarm panel and record the pressure reading before the morning delivery arrives.".to_string(),
                complete: false,
                latest_note: None,
            });
        })
        .with_title("Build Android and iOS apps in Rust")
        .mount("#fission-web-mount")
        .run()
        .map_err(|error| JsValue::from_str(&error.to_string()))
}
{"id":"fission-tabs-1"}

Run, test and build the finished project

Before running the app, follow the Android development setup guide to install the SDK and NDK, and the iOS development setup guide to install Xcode and the Rust targets. Those guides also cover starting an emulator or Simulator and connecting a device.
From the project root, list available devices, launch each target, then run the checks:
fission doctor --project-dir .
fission devices --project-dir .
fission run --target android --project-dir .
fission run --target ios --project-dir .
cargo test
fission build --target android --project-dir .
fission build --target ios --project-dir .
fission test --target android --project-dir .
fission test --target ios --project-dir .
Expected result: The native launchers use the same work-order model and reducers on Android and iOS; without a working record, they let the operator enter an existing handover. The screen adapts to each shell, shared status changes remain app data, and the unsaved note stays local to its editor.
fission run --target android launches the selected emulator or connected Android device. fission run --target ios launches an iOS Simulator; it does not install the app on a physical iPhone. Use the Android emulator guide or Android phone guide when you need those setup steps, and the iOS Simulator guide or physical iPhone guide for iOS.
Use these precise reference pages after the working path above is clear:
Keep an unsent note local and save it to shared state: Enter a shift note and save it. Confirm it appears on the work order and the draft clears.
Show the app preview
Hide the app preview