mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-04-03 10:11:15 +02:00
feat(cli): merge user-defined plist with the iOS plist file (#8200)
This commit is contained in:
committed by
GitHub
parent
adc3cc2ffa
commit
25e5f91dae
6
.changes/merge-ios-plist.md
Normal file
6
.changes/merge-ios-plist.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"tauri-cli": patch:feat
|
||||
"@tauri-apps/cli": patch:feat
|
||||
---
|
||||
|
||||
Merge `src-tauri/Info.plist` and `src-tauri/Info.ios.plist` with the iOS project plist file.
|
||||
1
tooling/cli/Cargo.lock
generated
1
tooling/cli/Cargo.lock
generated
@@ -4099,6 +4099,7 @@ dependencies = [
|
||||
"once_cell",
|
||||
"os_info",
|
||||
"os_pipe",
|
||||
"plist",
|
||||
"regex",
|
||||
"resvg",
|
||||
"semver",
|
||||
|
||||
@@ -102,6 +102,9 @@ cc = "1"
|
||||
[target."cfg(unix)".dependencies]
|
||||
libc = "0.2"
|
||||
|
||||
[target."cfg(target_os = \"macos\")".dependencies]
|
||||
plist = "1"
|
||||
|
||||
[features]
|
||||
default = [ "rustls" ]
|
||||
native-tls = [
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
use super::{
|
||||
configure_cargo, detect_target_ok, ensure_init, env, get_app, get_config, inject_assets,
|
||||
log_finished, open_and_wait, MobileTarget,
|
||||
log_finished, merge_plist, open_and_wait, MobileTarget,
|
||||
};
|
||||
use crate::{
|
||||
build::Options as BuildOptions,
|
||||
@@ -94,11 +94,23 @@ pub fn command(mut options: Options, noise_level: NoiseLevel) -> Result<()> {
|
||||
};
|
||||
|
||||
let tauri_path = tauri_dir();
|
||||
set_current_dir(tauri_path).with_context(|| "failed to change current working directory")?;
|
||||
set_current_dir(&tauri_path).with_context(|| "failed to change current working directory")?;
|
||||
|
||||
ensure_init(config.project_dir(), MobileTarget::Ios)?;
|
||||
inject_assets(&config)?;
|
||||
|
||||
let info_plist_path = config
|
||||
.project_dir()
|
||||
.join(config.scheme())
|
||||
.join("Info.plist");
|
||||
merge_plist(
|
||||
&[
|
||||
tauri_path.join("Info.plist"),
|
||||
tauri_path.join("Info.ios.plist"),
|
||||
],
|
||||
&info_plist_path,
|
||||
)?;
|
||||
|
||||
let mut env = env()?;
|
||||
configure_cargo(&app, None)?;
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
use super::{
|
||||
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,
|
||||
merge_plist, open_and_wait, setup_dev_config, MobileTarget, APPLE_DEVELOPMENT_TEAM_ENV_VAR_NAME,
|
||||
};
|
||||
use crate::{
|
||||
dev::Options as DevOptions,
|
||||
@@ -145,10 +145,23 @@ fn run_command(mut options: Options, noise_level: NoiseLevel) -> Result<()> {
|
||||
};
|
||||
|
||||
let tauri_path = tauri_dir();
|
||||
set_current_dir(tauri_path).with_context(|| "failed to change current working directory")?;
|
||||
set_current_dir(&tauri_path).with_context(|| "failed to change current working directory")?;
|
||||
|
||||
ensure_init(config.project_dir(), MobileTarget::Ios)?;
|
||||
inject_assets(&config)?;
|
||||
|
||||
let info_plist_path = config
|
||||
.project_dir()
|
||||
.join(config.scheme())
|
||||
.join("Info.plist");
|
||||
merge_plist(
|
||||
&[
|
||||
tauri_path.join("Info.plist"),
|
||||
tauri_path.join("Info.ios.plist"),
|
||||
],
|
||||
&info_plist_path,
|
||||
)?;
|
||||
|
||||
run_dev(options, tauri_config, &app, &config, noise_level)
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,14 @@ use super::{
|
||||
};
|
||||
use crate::{helpers::config::Config as TauriConfig, Result};
|
||||
|
||||
use std::{env::set_var, fs::create_dir_all, process::exit, thread::sleep, time::Duration};
|
||||
use std::{
|
||||
env::set_var,
|
||||
fs::create_dir_all,
|
||||
path::{Path, PathBuf},
|
||||
process::exit,
|
||||
thread::sleep,
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
mod build;
|
||||
mod dev;
|
||||
@@ -261,3 +268,30 @@ fn inject_assets(config: &AppleConfig) -> Result<()> {
|
||||
create_dir_all(asset_dir)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn merge_plist(src: &[PathBuf], dest: &Path) -> Result<()> {
|
||||
let mut dest_plist = None;
|
||||
|
||||
for src_path in src {
|
||||
if let Ok(src_plist) = plist::Value::from_file(src_path) {
|
||||
if dest_plist.is_none() {
|
||||
dest_plist.replace(plist::Value::from_file(dest)?);
|
||||
}
|
||||
|
||||
let plist = dest_plist.as_mut().expect("Info.plist not loaded");
|
||||
if let Some(plist) = plist.as_dictionary_mut() {
|
||||
if let Some(dict) = src_plist.into_dictionary() {
|
||||
for (key, value) in dict {
|
||||
plist.insert(key, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(dest_plist) = dest_plist {
|
||||
dest_plist.to_file_xml(dest)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user