diff --git a/.changes/fix-ide-build-run.md b/.changes/fix-ide-build-run.md new file mode 100644 index 000000000..f89fab21b --- /dev/null +++ b/.changes/fix-ide-build-run.md @@ -0,0 +1,6 @@ +--- +"tauri-cli": patch:bug +"@tauri-apps/cli": patch:bug +--- + +Fixes `android build --open` and `ios build --open` IDE failing to read CLI options. diff --git a/tooling/cli/src/mobile/android/build.rs b/tooling/cli/src/mobile/android/build.rs index 2cfa76c2a..d64196d15 100644 --- a/tooling/cli/src/mobile/android/build.rs +++ b/tooling/cli/src/mobile/android/build.rs @@ -4,7 +4,7 @@ use super::{ configure_cargo, delete_codegen_vars, ensure_init, env, get_app, get_config, inject_assets, - log_finished, open_and_wait, MobileTarget, + log_finished, open_and_wait, MobileTarget, OptionsHandle, }; use crate::{ build::Options as BuildOptions, @@ -131,7 +131,7 @@ pub fn command(mut options: Options, noise_level: NoiseLevel) -> Result<()> { )?; let open = options.open; - run_build( + let _handle = run_build( options, tauri_config, profile, @@ -154,7 +154,7 @@ fn run_build( config: &AndroidConfig, env: &mut Env, noise_level: NoiseLevel, -) -> Result<()> { +) -> Result { if !(options.apk || options.aab) { // if the user didn't specify the format to build, we'll do both options.apk = true; @@ -192,7 +192,7 @@ fn run_build( noise_level, vars: Default::default(), }; - let _handle = write_options( + let handle = write_options( &tauri_config .lock() .unwrap() @@ -240,7 +240,7 @@ fn run_build( log_finished(apk_outputs, "APK"); log_finished(aab_outputs, "AAB"); - Ok(()) + Ok(handle) } fn get_targets_or_all<'a>(targets: Vec) -> Result>> { diff --git a/tooling/cli/src/mobile/android/mod.rs b/tooling/cli/src/mobile/android/mod.rs index 1a622c7b4..d9ffeec5b 100644 --- a/tooling/cli/src/mobile/android/mod.rs +++ b/tooling/cli/src/mobile/android/mod.rs @@ -29,7 +29,7 @@ use sublime_fuzzy::best_match; use super::{ ensure_init, get_app, init::{command as init_command, configure_cargo}, - log_finished, read_options, setup_dev_config, CliOptions, Target as MobileTarget, + log_finished, read_options, setup_dev_config, CliOptions, OptionsHandle, Target as MobileTarget, MIN_DEVICE_MATCH_SCORE, }; use crate::{helpers::config::Config as TauriConfig, Result}; diff --git a/tooling/cli/src/mobile/ios/build.rs b/tooling/cli/src/mobile/ios/build.rs index 675fa5107..094489066 100644 --- a/tooling/cli/src/mobile/ios/build.rs +++ b/tooling/cli/src/mobile/ios/build.rs @@ -4,7 +4,7 @@ use super::{ configure_cargo, detect_target_ok, ensure_init, env, get_app, get_config, inject_assets, - log_finished, merge_plist, open_and_wait, MobileTarget, + log_finished, merge_plist, open_and_wait, MobileTarget, OptionsHandle, }; use crate::{ build::Options as BuildOptions, @@ -115,7 +115,7 @@ pub fn command(mut options: Options, noise_level: NoiseLevel) -> Result<()> { configure_cargo(&app, None)?; let open = options.open; - run_build(options, tauri_config, &config, &mut env, noise_level)?; + let _handle = run_build(options, tauri_config, &config, &mut env, noise_level)?; if open { open_and_wait(&config, &env); @@ -130,7 +130,7 @@ fn run_build( config: &AppleConfig, env: &mut Env, noise_level: NoiseLevel, -) -> Result<()> { +) -> Result { let profile = if options.debug { Profile::Debug } else { @@ -163,7 +163,7 @@ fn run_build( noise_level, vars: Default::default(), }; - let _handle = write_options( + let handle = write_options( &tauri_config .lock() .unwrap() @@ -211,5 +211,5 @@ fn run_build( log_finished(out_files, "IPA"); - Ok(()) + Ok(handle) } diff --git a/tooling/cli/src/mobile/ios/mod.rs b/tooling/cli/src/mobile/ios/mod.rs index ffbc77731..8b235e433 100644 --- a/tooling/cli/src/mobile/ios/mod.rs +++ b/tooling/cli/src/mobile/ios/mod.rs @@ -24,7 +24,7 @@ use sublime_fuzzy::best_match; use super::{ ensure_init, env, get_app, init::{command as init_command, configure_cargo}, - log_finished, read_options, setup_dev_config, CliOptions, Target as MobileTarget, + log_finished, read_options, setup_dev_config, CliOptions, OptionsHandle, Target as MobileTarget, MIN_DEVICE_MATCH_SCORE, }; use crate::{helpers::config::Config as TauriConfig, Result}; diff --git a/tooling/cli/src/mobile/mod.rs b/tooling/cli/src/mobile/mod.rs index 2534e6ecd..eeac3f0f1 100644 --- a/tooling/cli/src/mobile/mod.rs +++ b/tooling/cli/src/mobile/mod.rs @@ -217,11 +217,10 @@ fn env() -> Result { Ok(env) } +pub struct OptionsHandle(Runtime, ServerHandle); + /// Writes CLI options to be used later on the Xcode and Android Studio build commands -pub fn write_options( - identifier: &str, - mut options: CliOptions, -) -> crate::Result<(Runtime, ServerHandle)> { +pub fn write_options(identifier: &str, mut options: CliOptions) -> crate::Result { options.vars.extend(env_vars()); let runtime = Runtime::new().unwrap(); @@ -243,7 +242,7 @@ pub fn write_options( addr.to_string(), )?; - Ok((runtime, handle)) + Ok(OptionsHandle(runtime, handle)) } fn read_options(identifier: &str) -> CliOptions {