tauri-apps/tauri · error
Failed to render template
Error message
Failed to render template
What it means
When tauri.conf.json sets bundle > ios > template, `tauri ios init` reads that custom Xcode project template (a project.yml written with Handlebars placeholders) and renders it into the generated project. This expect fires when Handlebars fails to render the custom template — malformed Handlebars syntax in the file — or when writing the output project.yml fails.
Solutions
- Render the template standalone to see the real Handlebars error before running the CLI.
- Compare your template against the default project.yml template in the tauri repository for the block structure.
- Fix unbalanced {{#if}}/{{else}}/{{/if}} and {{#each}}/{{/each}} blocks and ensure variables referenced exist in the Tauri template data.
- Temporarily remove bundle.ios.template to confirm the default path works, then re-apply changes incrementally.
Example fix
{{! before: unclosed block }}
settings:
{{#if settings.base}}
base: {{settings.base}}
{{! after }}
settings:
{{#if settings.base}}
base: {{settings.base}}
{{/if}} Defensive patterns
Strategy: validation
Validate before calling
// Render the custom Xcode template once in a test to surface syntax errors early
#[test]
fn ios_template_is_valid() {
let mut hb = handlebars::Handlebars::new();
let src = std::fs::read_to_string("templates/ios-project.yml").unwrap();
hb.register_template_string("p.yml", src).expect("invalid Handlebars in ios template");
hb.render("p.yml", &serde_json::json!({})).unwrap();
} Prevention
- Keep custom bundle.ios.template files in the repo and CI-render them on every change.
- Diff against the upstream default project.yml template when upgrading Tauri versions.
- Use an editor with Handlebars syntax highlighting to catch unbalanced blocks.
When it happens
Trigger: Running `tauri ios init` (or first ios build that regenerates the project) with bundle.ios.template pointing at a project.yml containing invalid Handlebars expressions such as an unclosed {{#if}} without {{/if}}, or a mismatched block.
Common situations: Teams customizing the XcodeGen project template (extra build settings, entitlements) and introducing syntax errors; templates copied from blog posts with smart-quote mangled {{ }}.
Related errors
- iOS platform not installed
- Arch specified by Xcode was invalid.
- failed to read missing addr file
- Failed to render template
- failed to run on_webview_created hook
AI-assisted analysis of tauri-apps/tauri@52e4b6e71d (2026-08-20).
Data as JSON: /api/errors/d01e23788e3cb8ea.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tauri-cli/src/mobile/ios/project.rs:190
} else {
Ok(None)
}
},
)
.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).fs_context(
"failed to read custom Xcode project template",
template_path.to_path_buf(),
)?;
let mut output_file = std::fs::File::create(dest.join("project.yml")).fs_context(
"failed to create project.yml file",
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"));
dirs_to_create.push(dest.join(format!("{}_iOS", config.app().name())));
// Create all required project directories if they don't already exist
for dir in &dirs_to_create {
std::fs::create_dir_all(dir).fs_context("failed to create directory", dir.to_path_buf())?;
}
// Note that Xcode doesn't always reload the project nicely; reopening is
// often necessary.
println!("Generating Xcode project...");
duct::cmd(
"xcodegen",
[View on GitHub (pinned to 52e4b6e71d)