diff --git a/.changes/bundler-merge-info-plist.md b/.changes/bundler-merge-info-plist.md new file mode 100644 index 00000000000..545b18e71cb --- /dev/null +++ b/.changes/bundler-merge-info-plist.md @@ -0,0 +1,5 @@ +--- +"tauri-bundler": patch +--- + +Merge Tauri-generated Info.plist with the contents of `src-tauri/Info.plist` if it exists. diff --git a/.changes/embed-plist.md b/.changes/embed-plist.md new file mode 100644 index 00000000000..4939235333b --- /dev/null +++ b/.changes/embed-plist.md @@ -0,0 +1,6 @@ +--- +"tauri-codegen": patch +"tauri": patch +--- + +Embed Info.plist file contents on binary on dev. diff --git a/core/tauri-codegen/src/context.rs b/core/tauri-codegen/src/context.rs index 95509709b8f..293dbf18022 100644 --- a/core/tauri-codegen/src/context.rs +++ b/core/tauri-codegen/src/context.rs @@ -144,6 +144,25 @@ pub fn context_codegen(data: ContextData) -> Result Result { pub(crate) config: Config, pub(crate) assets: Arc, pub(crate) default_window_icon: Option>, pub(crate) system_tray_icon: Option, pub(crate) package_info: crate::api::PackageInfo, + pub(crate) _info_plist: (), +} + +impl fmt::Debug for Context { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("Context") + .field("config", &self.config) + .field("default_window_icon", &self.default_window_icon) + .field("system_tray_icon", &self.system_tray_icon) + .field("package_info", &self.package_info) + .finish() + } } impl Context { @@ -224,6 +238,7 @@ impl Context { default_window_icon: Option>, system_tray_icon: Option, package_info: crate::api::PackageInfo, + info_plist: (), ) -> Self { Self { config, @@ -231,6 +246,7 @@ impl Context { default_window_icon, system_tray_icon, package_info, + _info_plist: info_plist, } } } diff --git a/examples/api/src-tauri/Info.plist b/examples/api/src-tauri/Info.plist new file mode 100644 index 00000000000..fe253ec7ba0 --- /dev/null +++ b/examples/api/src-tauri/Info.plist @@ -0,0 +1,10 @@ + + + + + NSCameraUsageDescription + Request camera access for WebRTC + NSMicrophoneUsageDescription + Request microphone access for WebRTC + + diff --git a/tooling/bundler/src/bundle/macos/app.rs b/tooling/bundler/src/bundle/macos/app.rs index e12963e3c9c..7c239472987 100644 --- a/tooling/bundler/src/bundle/macos/app.rs +++ b/tooling/bundler/src/bundle/macos/app.rs @@ -181,7 +181,9 @@ fn create_info_plist( settings: &Settings, ) -> crate::Result<()> { let build_number = chrono::Utc::now().format("%Y%m%d.%H%M%S"); - let file = &mut common::create_file(&bundle_dir.join("Info.plist"))?; + + let bundle_plist_path = bundle_dir.join("Info.plist"); + let file = &mut common::create_file(&bundle_plist_path)?; let use_bootstrapper = settings.macos().use_bootstrapper.unwrap_or_default(); write!( file, @@ -296,6 +298,27 @@ fn create_info_plist( write!(file, "\n\n")?; file.flush()?; + + if let Some(user_plist_path) = &settings.macos().info_plist_path { + let mut cmd = Command::new("/usr/libexec/PlistBuddy"); + cmd.args(&[ + "-c".into(), + format!("Merge {}", user_plist_path.display()), + bundle_plist_path.display().to_string(), + ]); + + common::execute_with_verbosity(&mut cmd, settings).map_err(|_| { + crate::Error::ShellScriptError(format!( + "error running /usr/libexec/PlistBuddy{}", + if settings.is_verbose() { + "" + } else { + ", try running with --verbose to see command output" + } + )) + })?; + } + Ok(()) } diff --git a/tooling/bundler/src/bundle/settings.rs b/tooling/bundler/src/bundle/settings.rs index 24e14cdf65f..b205ba6d1ac 100644 --- a/tooling/bundler/src/bundle/settings.rs +++ b/tooling/bundler/src/bundle/settings.rs @@ -170,6 +170,8 @@ pub struct MacOsSettings { pub signing_identity: Option, /// Path to the entitlements.plist file. pub entitlements: Option, + /// Path to the Info.plist file for the bundle. + pub info_plist_path: Option, } /// Settings specific to the WiX implementation. diff --git a/tooling/cli.rs/src/interface/rust.rs b/tooling/cli.rs/src/interface/rust.rs index 74a6a1d2a20..91bfcc65ca4 100644 --- a/tooling/cli.rs/src/interface/rust.rs +++ b/tooling/cli.rs/src/interface/rust.rs @@ -436,6 +436,14 @@ fn tauri_config_to_bundle_settings( exception_domain: config.macos.exception_domain, signing_identity, entitlements: config.macos.entitlements, + info_plist_path: { + let path = tauri_dir().join("Info.plist"); + if path.exists() { + Some(path) + } else { + None + } + }, }, windows: WindowsSettings { timestamp_url: config.windows.timestamp_url,