diff --git a/.changes/ios-create-asset-dir.md b/.changes/ios-create-asset-dir.md new file mode 100644 index 000000000000..9753aa6e257b --- /dev/null +++ b/.changes/ios-create-asset-dir.md @@ -0,0 +1,6 @@ +--- +"tauri-cli": patch:bug +"@tauri-apps/cli": patch:bug +--- + +Ensure asset directory exists on the iOS project. diff --git a/tooling/cli/src/mobile/android.rs b/tooling/cli/src/mobile/android.rs index 9f1b43ace9a2..6913cfe5d2b9 100644 --- a/tooling/cli/src/mobile/android.rs +++ b/tooling/cli/src/mobile/android.rs @@ -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, @@ -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( diff --git a/tooling/cli/src/mobile/ios.rs b/tooling/cli/src/mobile/ios.rs index 05401a5bfda2..db6011bdc4f7 100644 --- a/tooling/cli/src/mobile/ios.rs +++ b/tooling/cli/src/mobile/ios.rs @@ -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, @@ -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; @@ -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(()) +} diff --git a/tooling/cli/src/mobile/ios/build.rs b/tooling/cli/src/mobile/ios/build.rs index 5ee74fbfe9ed..8d9485acadf4 100644 --- a/tooling/cli/src/mobile/ios/build.rs +++ b/tooling/cli/src/mobile/ios/build.rs @@ -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, @@ -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)?; diff --git a/tooling/cli/src/mobile/ios/dev.rs b/tooling/cli/src/mobile/ios/dev.rs index 1e2b9ede52c5..ba65c91b7d72 100644 --- a/tooling/cli/src/mobile/ios/dev.rs +++ b/tooling/cli/src/mobile/ios/dev.rs @@ -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, @@ -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) } diff --git a/tooling/cli/src/mobile/ios/open.rs b/tooling/cli/src/mobile/ios/open.rs index b9e8d2b419ea..82a9b56833dc 100644 --- a/tooling/cli/src/mobile/ios/open.rs +++ b/tooling/cli/src/mobile/ios/open.rs @@ -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; @@ -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) }