polyhorn_cli/ios/tasks/
run_on_ios_simulator.rs

1use simctl::Device;
2
3use super::{IOSContext, IOSError};
4use crate::core::{Manager, Task};
5
6/// This task launches the application on an iOS Simulator with the given
7/// identifier.
8pub struct RunOnIOSSimulator {
9    /// The iOS Simulator on which to launch the application.
10    pub device: Device,
11
12    /// Additional environment variables that should be passed to the
13    /// application.
14    pub env: Vec<(String, String)>,
15}
16
17impl Task for RunOnIOSSimulator {
18    type Context = IOSContext;
19    type Error = IOSError;
20
21    fn verb(&self) -> &str {
22        "Running"
23    }
24
25    fn message(&self) -> &str {
26        "on iOS Simulator"
27    }
28
29    fn detail(&self) -> &str {
30        &self.device.name
31    }
32
33    fn run(
34        &self,
35        context: Self::Context,
36        _manager: &mut Manager,
37    ) -> Result<Self::Context, Self::Error> {
38        eprintln!("");
39
40        let mut launch = self
41            .device
42            .launch(&context.config.spec.app.ios.bundle_identifier);
43
44        for (name, value) in self.env.iter() {
45            launch.env(name, value);
46        }
47
48        launch.exec()?;
49
50        Ok(context)
51    }
52}