polyhorn_cli/ios/tasks/
install_on_ios_simulator.rs

1use simctl::Device;
2
3use super::{IOSContext, IOSError};
4use crate::core::{Manager, Task};
5
6/// This task installs an application on the iOS Simulator with the given
7/// identifier.
8pub struct InstallOnIOSSimulator {
9    /// Configuration with which the application was built, which is used to
10    /// locate its path.
11    pub configuration: String,
12
13    /// iOS Simulator on which the application will be installed.
14    pub device: Device,
15}
16
17impl Task for InstallOnIOSSimulator {
18    type Context = IOSContext;
19    type Error = IOSError;
20
21    fn verb(&self) -> &str {
22        "Installing"
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        let target_dir = context.config.target_dir.join("polyhorn-ios");
39
40        self.device.install(
41            &target_dir.join(
42                format!(
43                    "derived-data/Build/Products/{}-iphonesimulator/{}.app",
44                    self.configuration, context.config.spec.app.name
45                )
46                .as_str(),
47            ),
48        )?;
49
50        Ok(context)
51    }
52}