{"record":{"id":"d01e23788e3cb8ea","repo":"tauri-apps/tauri","slug":"failed-to-render-template-d01e23","errorCode":null,"errorMessage":"Failed to render template","messagePattern":"Failed to render template","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tauri-cli/src/mobile/ios/project.rs","lineNumber":190,"sourceCode":"      } else {\n        Ok(None)\n      }\n    },\n  )\n  .with_context(|| \"failed to process template\")?;\n\n  if let Some(template_path) = tauri_config.bundle.ios.template.as_ref() {\n    let template = std::fs::read_to_string(template_path).fs_context(\n      \"failed to read custom Xcode project template\",\n      template_path.to_path_buf(),\n    )?;\n    let mut output_file = std::fs::File::create(dest.join(\"project.yml\")).fs_context(\n      \"failed to create project.yml file\",\n      dest.join(\"project.yml\"),\n    )?;\n    handlebars\n      .render_template_to_write(&template, map.inner(), &mut output_file)\n      .expect(\"Failed to render template\");\n  }\n\n  let mut dirs_to_create = asset_catalogs.to_vec();\n  dirs_to_create.push(dest.join(DEFAULT_ASSET_DIR));\n  dirs_to_create.push(dest.join(\"Externals\"));\n  dirs_to_create.push(dest.join(format!(\"{}_iOS\", config.app().name())));\n\n  // Create all required project directories if they don't already exist\n  for dir in &dirs_to_create {\n    std::fs::create_dir_all(dir).fs_context(\"failed to create directory\", dir.to_path_buf())?;\n  }\n\n  // Note that Xcode doesn't always reload the project nicely; reopening is\n  // often necessary.\n  println!(\"Generating Xcode project...\");\n  duct::cmd(\n    \"xcodegen\",\n    [","sourceCodeStart":172,"sourceCodeEnd":208,"githubUrl":"https://github.com/tauri-apps/tauri/blob/52e4b6e71d8632a7e648f866c442e287ecddee34/crates/tauri-cli/src/mobile/ios/project.rs#L172-L208","documentation":"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.","triggerScenarios":"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.","commonSituations":"Teams customizing the XcodeGen project template (extra build settings, entitlements) and introducing syntax errors; templates copied from blog posts with smart-quote mangled {{ }}.","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."],"exampleFix":"{{! before: unclosed block }}\nsettings:\n  {{#if settings.base}}\n  base: {{settings.base}}\n\n{{! after }}\nsettings:\n  {{#if settings.base}}\n  base: {{settings.base}}\n  {{/if}}","handlingStrategy":"validation","validationCode":"// Render the custom Xcode template once in a test to surface syntax errors early\n#[test]\nfn ios_template_is_valid() {\n    let mut hb = handlebars::Handlebars::new();\n    let src = std::fs::read_to_string(\"templates/ios-project.yml\").unwrap();\n    hb.register_template_string(\"p.yml\", src).expect(\"invalid Handlebars in ios template\");\n    hb.render(\"p.yml\", &serde_json::json!({})).unwrap();\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["ios","mobile","xcode","xcodegen","handlebars","template"],"backgroundTag":"template-render-failed","analyzedSha":"52e4b6e71d8632a7e648f866c442e287ecddee34","analyzedAt":"2026-08-20T13:59:20.734Z","contentChangedAt":"2026-08-20T13:59:20.734Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}