polyhorn_cli/ios/tasks/
open_ios_simulator.rs

1use std::process::{Command, Stdio};
2
3use super::{IOSContext, IOSError};
4use crate::core::{Manager, Task};
5
6/// This task opens the iOS Simulator GUI, which is not open by default when
7/// booting a (new) simulator.
8pub struct OpenIOSSimulator;
9
10impl Task for OpenIOSSimulator {
11    type Context = IOSContext;
12    type Error = IOSError;
13
14    fn verb(&self) -> &str {
15        "Opening"
16    }
17
18    fn message(&self) -> &str {
19        "iOS Simulator"
20    }
21
22    fn detail(&self) -> &str {
23        ""
24    }
25
26    fn run(
27        &self,
28        context: Self::Context,
29        _manager: &mut Manager,
30    ) -> Result<Self::Context, Self::Error> {
31        Command::new("open")
32            .arg("-a")
33            .arg("Simulator.app")
34            .stdout(Stdio::null())
35            .current_dir(context.config.target_dir.join("polyhorn-ios"))
36            .spawn()
37            .unwrap()
38            .wait()
39            .unwrap();
40
41        Ok(context)
42    }
43}