|
@@ -1,8 +1,9 @@
|
|
|
use super::{
|
|
|
- device_prompt, ensure_init, env, init_dot_cargo, open_and_wait, with_config, MobileTarget,
|
|
|
- APPLE_DEVELOPMENT_TEAM_ENV_VAR_NAME,
|
|
|
+ device_prompt, ensure_init, env, init_dot_cargo, open_and_wait, setup_dev_config, with_config,
|
|
|
+ MobileTarget, APPLE_DEVELOPMENT_TEAM_ENV_VAR_NAME,
|
|
|
};
|
|
|
use crate::{
|
|
|
+ dev::Options as DevOptions,
|
|
|
helpers::flock,
|
|
|
interface::{AppSettings, Interface, MobileOptions, Options as InterfaceOptions},
|
|
|
mobile::{write_options, CliOptions, DevChild, DevProcess},
|
|
@@ -12,7 +13,7 @@ use clap::{ArgAction, Parser};
|
|
|
|
|
|
use dialoguer::{theme::ColorfulTheme, Select};
|
|
|
use tauri_mobile::{
|
|
|
- apple::{config::Config as AppleConfig, teams::find_development_teams},
|
|
|
+ apple::{config::Config as AppleConfig, device::Device, teams::find_development_teams},
|
|
|
config::app::App,
|
|
|
env::Env,
|
|
|
opts::{NoiseLevel, Profile},
|
|
@@ -48,7 +49,7 @@ pub struct Options {
|
|
|
pub device: Option<String>,
|
|
|
}
|
|
|
|
|
|
-impl From<Options> for crate::dev::Options {
|
|
|
+impl From<Options> for DevOptions {
|
|
|
fn from(options: Options) -> Self {
|
|
|
Self {
|
|
|
runner: None,
|
|
@@ -105,12 +106,28 @@ pub fn command(options: Options, noise_level: NoiseLevel) -> Result<()> {
|
|
|
}
|
|
|
|
|
|
fn run_dev(
|
|
|
- options: Options,
|
|
|
+ mut options: Options,
|
|
|
app: &App,
|
|
|
config: &AppleConfig,
|
|
|
noise_level: NoiseLevel,
|
|
|
) -> Result<()> {
|
|
|
- let mut dev_options = options.clone().into();
|
|
|
+ setup_dev_config(&mut options.config)?;
|
|
|
+ let env = env()?;
|
|
|
+ let device = match device_prompt(&env, options.device.as_deref()) {
|
|
|
+ Ok(d) => Some(d),
|
|
|
+ Err(e) => {
|
|
|
+ log::error!("{e}");
|
|
|
+ None
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ let mut dev_options: DevOptions = options.clone().into();
|
|
|
+ dev_options.target = Some(
|
|
|
+ device
|
|
|
+ .as_ref()
|
|
|
+ .map(|d| d.target().triple.to_string())
|
|
|
+ .unwrap_or_else(|| "aarch64-apple-ios".into()),
|
|
|
+ );
|
|
|
let mut interface = crate::dev::setup(&mut dev_options, true)?;
|
|
|
|
|
|
let app_settings = interface.app_settings();
|
|
@@ -121,13 +138,11 @@ fn run_dev(
|
|
|
let out_dir = bin_path.parent().unwrap();
|
|
|
let _lock = flock::open_rw(&out_dir.join("lock").with_extension("ios"), "iOS")?;
|
|
|
|
|
|
- let env = env()?;
|
|
|
init_dot_cargo(app, None)?;
|
|
|
|
|
|
let open = options.open;
|
|
|
let exit_on_panic = options.exit_on_panic;
|
|
|
let no_watch = options.no_watch;
|
|
|
- let device = options.device;
|
|
|
interface.mobile_dev(
|
|
|
MobileOptions {
|
|
|
debug: true,
|
|
@@ -148,23 +163,21 @@ fn run_dev(
|
|
|
|
|
|
if open {
|
|
|
open_and_wait(config, &env)
|
|
|
- } else {
|
|
|
- match run(device.as_deref(), options, config, &env) {
|
|
|
+ } else if let Some(device) = &device {
|
|
|
+ match run(device, options, config, &env) {
|
|
|
Ok(c) => {
|
|
|
crate::dev::wait_dev_process(c.clone(), move |status, reason| {
|
|
|
crate::dev::on_app_exit(status, reason, exit_on_panic, no_watch)
|
|
|
});
|
|
|
Ok(Box::new(c) as Box<dyn DevProcess>)
|
|
|
}
|
|
|
- Err(RunError::FailedToPromptForDevice(e)) => {
|
|
|
- log::error!("{}", e);
|
|
|
- open_and_wait(config, &env)
|
|
|
- }
|
|
|
Err(e) => {
|
|
|
crate::dev::kill_before_dev_process();
|
|
|
Err(e.into())
|
|
|
}
|
|
|
}
|
|
|
+ } else {
|
|
|
+ open_and_wait(config, &env)
|
|
|
}
|
|
|
},
|
|
|
)
|
|
@@ -172,13 +185,11 @@ fn run_dev(
|
|
|
|
|
|
#[derive(Debug, thiserror::Error)]
|
|
|
enum RunError {
|
|
|
- #[error("{0}")]
|
|
|
- FailedToPromptForDevice(String),
|
|
|
#[error("{0}")]
|
|
|
RunFailed(String),
|
|
|
}
|
|
|
fn run(
|
|
|
- device: Option<&str>,
|
|
|
+ device: &Device<'_>,
|
|
|
options: MobileOptions,
|
|
|
config: &AppleConfig,
|
|
|
env: &Env,
|
|
@@ -189,8 +200,7 @@ fn run(
|
|
|
Profile::Release
|
|
|
};
|
|
|
|
|
|
- device_prompt(env, device)
|
|
|
- .map_err(|e| RunError::FailedToPromptForDevice(e.to_string()))?
|
|
|
+ device
|
|
|
.run(
|
|
|
config,
|
|
|
env,
|