Skip to content

Commit

Permalink
fix(cli): missing assets dir on iOS project when it is committed (#7765)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog committed Sep 6, 2023
1 parent b7f53d6 commit 8faa5a4
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 9 deletions.
6 changes: 6 additions & 0 deletions .changes/ios-create-asset-dir.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"tauri-cli": patch:bug
"@tauri-apps/cli": patch:bug
---

Ensure asset directory exists on the iOS project.
7 changes: 5 additions & 2 deletions tooling/cli/src/mobile/android.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use tauri_mobile::{
env::Env,
target::Target,
},
config::app::App,
config::app::{App, DEFAULT_ASSET_DIR},
opts::{FilterLevel, NoiseLevel},
os,
util::prompt,
Expand Down Expand Up @@ -292,7 +292,10 @@ fn open_and_wait(config: &AndroidConfig, env: &Env) -> ! {
}

fn inject_assets(config: &AndroidConfig, tauri_config: &TauriConfig) -> Result<()> {
let asset_dir = config.project_dir().join("app/src/main/assets");
let asset_dir = config
.project_dir()
.join("app/src/main")
.join(DEFAULT_ASSET_DIR);
create_dir_all(&asset_dir)?;

write(
Expand Down
10 changes: 8 additions & 2 deletions tooling/cli/src/mobile/ios.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use tauri_mobile::{
target::Target,
teams::find_development_teams,
},
config::app::App,
config::app::{App, DEFAULT_ASSET_DIR},
env::Env,
opts::NoiseLevel,
os,
Expand All @@ -30,7 +30,7 @@ use super::{
};
use crate::{helpers::config::Config as TauriConfig, Result};

use std::{env::set_var, process::exit, thread::sleep, time::Duration};
use std::{env::set_var, fs::create_dir_all, process::exit, thread::sleep, time::Duration};

mod build;
mod dev;
Expand Down Expand Up @@ -256,3 +256,9 @@ fn open_and_wait(config: &AppleConfig, env: &Env) -> ! {
sleep(Duration::from_secs(24 * 60 * 60));
}
}

fn inject_assets(config: &AppleConfig) -> Result<()> {
let asset_dir = config.project_dir().join(DEFAULT_ASSET_DIR);
create_dir_all(asset_dir)?;
Ok(())
}
5 changes: 3 additions & 2 deletions tooling/cli/src/mobile/ios/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
// SPDX-License-Identifier: MIT

use super::{
configure_cargo, detect_target_ok, ensure_init, env, get_app, get_config, log_finished,
open_and_wait, MobileTarget,
configure_cargo, detect_target_ok, ensure_init, env, get_app, get_config, inject_assets,
log_finished, open_and_wait, MobileTarget,
};
use crate::{
build::Options as BuildOptions,
Expand Down Expand Up @@ -91,6 +91,7 @@ pub fn command(mut options: Options, noise_level: NoiseLevel) -> Result<()> {
set_current_dir(tauri_path).with_context(|| "failed to change current working directory")?;

ensure_init(config.project_dir(), MobileTarget::Ios)?;
inject_assets(&config)?;

let mut env = env()?;
configure_cargo(&app, None)?;
Expand Down
5 changes: 3 additions & 2 deletions tooling/cli/src/mobile/ios/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
// SPDX-License-Identifier: MIT

use super::{
configure_cargo, device_prompt, ensure_init, env, get_app, get_config, open_and_wait,
setup_dev_config, MobileTarget, APPLE_DEVELOPMENT_TEAM_ENV_VAR_NAME,
configure_cargo, device_prompt, ensure_init, env, get_app, get_config, inject_assets,
open_and_wait, setup_dev_config, MobileTarget, APPLE_DEVELOPMENT_TEAM_ENV_VAR_NAME,
};
use crate::{
dev::Options as DevOptions,
Expand Down Expand Up @@ -139,6 +139,7 @@ fn run_command(mut options: Options, noise_level: NoiseLevel) -> Result<()> {
set_current_dir(tauri_path).with_context(|| "failed to change current working directory")?;

ensure_init(config.project_dir(), MobileTarget::Ios)?;
inject_assets(&config)?;
run_dev(options, tauri_config, &app, &config, noise_level)
}

Expand Down
3 changes: 2 additions & 1 deletion tooling/cli/src/mobile/ios/open.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT

use super::{ensure_init, env, get_app, get_config, MobileTarget};
use super::{ensure_init, env, get_app, get_config, inject_assets, MobileTarget};
use crate::{helpers::config::get as get_tauri_config, Result};

use tauri_mobile::os;
Expand All @@ -17,6 +17,7 @@ pub fn command() -> Result<()> {
};

ensure_init(config.project_dir(), MobileTarget::Ios)?;
inject_assets(&config)?;
let env = env()?;
os::open_file_with("Xcode", config.project_dir(), &env).map_err(Into::into)
}

0 comments on commit 8faa5a4

Please sign in to comment.