Skip to content

Commit 977d0e5

Browse files
authored
fix(cli): IDE failing to read CLI options on build --open commands (#8202)
1 parent ecb5b0c commit 977d0e5

File tree

6 files changed

+22
-17
lines changed

6 files changed

+22
-17
lines changed

.changes/fix-ide-build-run.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"tauri-cli": patch:bug
3+
"@tauri-apps/cli": patch:bug
4+
---
5+
6+
Fixes `android build --open` and `ios build --open` IDE failing to read CLI options.

tooling/cli/src/mobile/android/build.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use super::{
66
configure_cargo, delete_codegen_vars, ensure_init, env, get_app, get_config, inject_assets,
7-
log_finished, open_and_wait, MobileTarget,
7+
log_finished, open_and_wait, MobileTarget, OptionsHandle,
88
};
99
use crate::{
1010
build::Options as BuildOptions,
@@ -131,7 +131,7 @@ pub fn command(mut options: Options, noise_level: NoiseLevel) -> Result<()> {
131131
)?;
132132

133133
let open = options.open;
134-
run_build(
134+
let _handle = run_build(
135135
options,
136136
tauri_config,
137137
profile,
@@ -154,7 +154,7 @@ fn run_build(
154154
config: &AndroidConfig,
155155
env: &mut Env,
156156
noise_level: NoiseLevel,
157-
) -> Result<()> {
157+
) -> Result<OptionsHandle> {
158158
if !(options.apk || options.aab) {
159159
// if the user didn't specify the format to build, we'll do both
160160
options.apk = true;
@@ -192,7 +192,7 @@ fn run_build(
192192
noise_level,
193193
vars: Default::default(),
194194
};
195-
let _handle = write_options(
195+
let handle = write_options(
196196
&tauri_config
197197
.lock()
198198
.unwrap()
@@ -240,7 +240,7 @@ fn run_build(
240240
log_finished(apk_outputs, "APK");
241241
log_finished(aab_outputs, "AAB");
242242

243-
Ok(())
243+
Ok(handle)
244244
}
245245

246246
fn get_targets_or_all<'a>(targets: Vec<String>) -> Result<Vec<&'a Target<'a>>> {

tooling/cli/src/mobile/android/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use sublime_fuzzy::best_match;
2929
use super::{
3030
ensure_init, get_app,
3131
init::{command as init_command, configure_cargo},
32-
log_finished, read_options, setup_dev_config, CliOptions, Target as MobileTarget,
32+
log_finished, read_options, setup_dev_config, CliOptions, OptionsHandle, Target as MobileTarget,
3333
MIN_DEVICE_MATCH_SCORE,
3434
};
3535
use crate::{helpers::config::Config as TauriConfig, Result};

tooling/cli/src/mobile/ios/build.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use super::{
66
configure_cargo, detect_target_ok, ensure_init, env, get_app, get_config, inject_assets,
7-
log_finished, merge_plist, open_and_wait, MobileTarget,
7+
log_finished, merge_plist, open_and_wait, MobileTarget, OptionsHandle,
88
};
99
use crate::{
1010
build::Options as BuildOptions,
@@ -115,7 +115,7 @@ pub fn command(mut options: Options, noise_level: NoiseLevel) -> Result<()> {
115115
configure_cargo(&app, None)?;
116116

117117
let open = options.open;
118-
run_build(options, tauri_config, &config, &mut env, noise_level)?;
118+
let _handle = run_build(options, tauri_config, &config, &mut env, noise_level)?;
119119

120120
if open {
121121
open_and_wait(&config, &env);
@@ -130,7 +130,7 @@ fn run_build(
130130
config: &AppleConfig,
131131
env: &mut Env,
132132
noise_level: NoiseLevel,
133-
) -> Result<()> {
133+
) -> Result<OptionsHandle> {
134134
let profile = if options.debug {
135135
Profile::Debug
136136
} else {
@@ -163,7 +163,7 @@ fn run_build(
163163
noise_level,
164164
vars: Default::default(),
165165
};
166-
let _handle = write_options(
166+
let handle = write_options(
167167
&tauri_config
168168
.lock()
169169
.unwrap()
@@ -211,5 +211,5 @@ fn run_build(
211211

212212
log_finished(out_files, "IPA");
213213

214-
Ok(())
214+
Ok(handle)
215215
}

tooling/cli/src/mobile/ios/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use sublime_fuzzy::best_match;
2424
use super::{
2525
ensure_init, env, get_app,
2626
init::{command as init_command, configure_cargo},
27-
log_finished, read_options, setup_dev_config, CliOptions, Target as MobileTarget,
27+
log_finished, read_options, setup_dev_config, CliOptions, OptionsHandle, Target as MobileTarget,
2828
MIN_DEVICE_MATCH_SCORE,
2929
};
3030
use crate::{helpers::config::Config as TauriConfig, Result};

tooling/cli/src/mobile/mod.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,10 @@ fn env() -> Result<Env, EnvError> {
217217
Ok(env)
218218
}
219219

220+
pub struct OptionsHandle(Runtime, ServerHandle);
221+
220222
/// Writes CLI options to be used later on the Xcode and Android Studio build commands
221-
pub fn write_options(
222-
identifier: &str,
223-
mut options: CliOptions,
224-
) -> crate::Result<(Runtime, ServerHandle)> {
223+
pub fn write_options(identifier: &str, mut options: CliOptions) -> crate::Result<OptionsHandle> {
225224
options.vars.extend(env_vars());
226225

227226
let runtime = Runtime::new().unwrap();
@@ -243,7 +242,7 @@ pub fn write_options(
243242
addr.to_string(),
244243
)?;
245244

246-
Ok((runtime, handle))
245+
Ok(OptionsHandle(runtime, handle))
247246
}
248247

249248
fn read_options(identifier: &str) -> CliOptions {

0 commit comments

Comments
 (0)