crossbundle_tools/commands/apple/
launch_app.rs

1use crate::error::*;
2use simctl::{list::DeviceState, Device, DeviceQuery, Simctl};
3use std::path::Path;
4
5pub fn launch_apple_app(
6    app_path: &Path,
7    device_name: &str,
8    bundle_id: &str,
9    open: bool,
10) -> Result<Device> {
11    let simctl = Simctl::new();
12    let device_list = simctl.list()?;
13    let device = device_list
14        .devices()
15        .iter()
16        .available()
17        .by_name(device_name)
18        .next()
19        .unwrap();
20    if device.state != DeviceState::Booted {
21        device.boot()?;
22    }
23    device.install(app_path)?;
24    if open {
25        simctl.open()?;
26    }
27    device.launch(bundle_id).use_pty(true).exec()?;
28    Ok(device.clone())
29}