diff --git a/.changes/ios-custom-project-template.md b/.changes/ios-custom-project-template.md new file mode 100644 index 000000000..2788ec0e7 --- /dev/null +++ b/.changes/ios-custom-project-template.md @@ -0,0 +1,7 @@ +--- +"tauri-utils": patch:feat +"tauri-cli": patch:feat +"@tauri-apps/cli": patch:feat +--- + +Added `bundle > ios > template` configuration option for custom Xcode project YML Handlebars template using XcodeGen. diff --git a/core/tauri-config-schema/schema.json b/core/tauri-config-schema/schema.json index 7fc57da2d..3f0bf828f 100644 --- a/core/tauri-config-schema/schema.json +++ b/core/tauri-config-schema/schema.json @@ -2900,6 +2900,13 @@ "description": "General configuration for the iOS target.", "type": "object", "properties": { + "template": { + "description": "A custom [XcodeGen] project.yml template to use.\n\n [XcodeGen]: ", + "type": [ + "string", + "null" + ] + }, "frameworks": { "description": "A list of strings indicating any iOS frameworks that need to be bundled with the application.\n\n Note that you need to recreate the iOS project for the changes to be applied.", "type": [ diff --git a/core/tauri-utils/src/config.rs b/core/tauri-utils/src/config.rs index dc088a465..e0431e89f 100644 --- a/core/tauri-utils/src/config.rs +++ b/core/tauri-utils/src/config.rs @@ -1893,6 +1893,10 @@ pub struct TrayIconConfig { #[cfg_attr(feature = "schema", derive(JsonSchema))] #[serde(rename_all = "camelCase", deny_unknown_fields)] pub struct IosConfig { + /// A custom [XcodeGen] project.yml template to use. + /// + /// [XcodeGen]: + pub template: Option, /// A list of strings indicating any iOS frameworks that need to be bundled with the application. /// /// Note that you need to recreate the iOS project for the changes to be applied. diff --git a/tooling/cli/schema.json b/tooling/cli/schema.json index 7fc57da2d..3f0bf828f 100644 --- a/tooling/cli/schema.json +++ b/tooling/cli/schema.json @@ -2900,6 +2900,13 @@ "description": "General configuration for the iOS target.", "type": "object", "properties": { + "template": { + "description": "A custom [XcodeGen] project.yml template to use.\n\n [XcodeGen]: ", + "type": [ + "string", + "null" + ] + }, "frameworks": { "description": "A list of strings indicating any iOS frameworks that need to be bundled with the application.\n\n Note that you need to recreate the iOS project for the changes to be applied.", "type": [ diff --git a/tooling/cli/src/mobile/init.rs b/tooling/cli/src/mobile/init.rs index 58922185a..b005d587c 100644 --- a/tooling/cli/src/mobile/init.rs +++ b/tooling/cli/src/mobile/init.rs @@ -221,6 +221,7 @@ pub fn exec( super::ios::get_config(&app, tauri_config_, None, &Default::default()); map.insert("apple", &config); super::ios::project::gen( + tauri_config_, &config, &metadata, (handlebars, map), diff --git a/tooling/cli/src/mobile/ios/project.rs b/tooling/cli/src/mobile/ios/project.rs index 3efafe33e..4cb2789b3 100644 --- a/tooling/cli/src/mobile/ios/project.rs +++ b/tooling/cli/src/mobile/ios/project.rs @@ -2,7 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -use crate::{helpers::template, Result}; +use crate::{ + helpers::{config::Config as TauriConfig, template}, + Result, +}; use anyhow::Context; use cargo_mobile2::{ apple::{ @@ -27,6 +30,7 @@ const TEMPLATE_DIR: Dir<'_> = include_dir!("$CARGO_MANIFEST_DIR/templates/mobile // unprefixed app_root seems pretty dangerous!! // TODO: figure out what cargo-mobile meant by that pub fn gen( + tauri_config: &TauriConfig, config: &Config, metadata: &Metadata, (handlebars, mut map): (Handlebars, template::JsonMap), @@ -164,6 +168,15 @@ pub fn gen( ) .with_context(|| "failed to process template")?; + if let Some(template_path) = tauri_config.bundle.ios.template.as_ref() { + let template = std::fs::read_to_string(template_path) + .context("failed to read custom Xcode project template")?; + let mut output_file = std::fs::File::create(dest.join("project.yml"))?; + handlebars + .render_template_to_write(&template, map.inner(), &mut output_file) + .expect("Failed to render template"); + } + let mut dirs_to_create = asset_catalogs.to_vec(); dirs_to_create.push(dest.join(DEFAULT_ASSET_DIR)); dirs_to_create.push(dest.join("Externals"));