mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-02-06 13:57:16 +00:00
feat(core): add option for custom Xcode project template (XcodeGen) (#10496)
This commit is contained in:
parent
02c00abc63
commit
8dc81b6cc2
7
.changes/ios-custom-project-template.md
Normal file
7
.changes/ios-custom-project-template.md
Normal file
@ -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.
|
||||
@ -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]: <https://github.com/yonaskolb/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": [
|
||||
|
||||
@ -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]: <https://github.com/yonaskolb/XcodeGen>
|
||||
pub template: Option<PathBuf>,
|
||||
/// 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.
|
||||
|
||||
@ -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]: <https://github.com/yonaskolb/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": [
|
||||
|
||||
@ -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),
|
||||
|
||||
@ -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"));
|
||||
|
||||
Loading…
Reference in New Issue
Block a user