1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
use simctl::Device;

use super::{IOSContext, IOSError};
use crate::core::{Manager, Task};

/// This task installs an application on the iOS Simulator with the given
/// identifier.
pub struct InstallOnIOSSimulator {
    /// Configuration with which the application was built, which is used to
    /// locate its path.
    pub configuration: String,

    /// iOS Simulator on which the application will be installed.
    pub device: Device,
}

impl Task for InstallOnIOSSimulator {
    type Context = IOSContext;
    type Error = IOSError;

    fn verb(&self) -> &str {
        "Installing"
    }

    fn message(&self) -> &str {
        "on iOS Simulator"
    }

    fn detail(&self) -> &str {
        &self.device.name
    }

    fn run(
        &self,
        context: Self::Context,
        _manager: &mut Manager,
    ) -> Result<Self::Context, Self::Error> {
        let target_dir = context.config.target_dir.join("polyhorn-ios");

        self.device.install(
            &target_dir.join(
                format!(
                    "derived-data/Build/Products/{}-iphonesimulator/{}.app",
                    self.configuration, context.config.spec.app.name
                )
                .as_str(),
            ),
        )?;

        Ok(context)
    }
}