Skip to content

Commit 1f6e478

Browse files
olexiyblucasfernog
andauthored
fix: #7614 - rebuild every time on macos because of Info.plist changes (#9878)
* fix: #7614: rebuild every time on macos because of Info.plist changes * apply proposed patch from lucasfernog * Update core/tauri-codegen/src/context.rs Co-authored-by: Lucas Fernandes Nogueira <lucas@tauri.app> * Update core/tauri-codegen/src/context.rs Co-authored-by: Lucas Fernandes Nogueira <lucas@tauri.app> * added changes file --------- Co-authored-by: Lucas Fernandes Nogueira <lucas@tauri.app>
1 parent 7d85f7c commit 1f6e478

2 files changed

Lines changed: 18 additions & 7 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri-codegen": patch:bug
3+
---
4+
5+
Fixes Info.plist rewriting always triggering build to rerun.

‎core/tauri-codegen/src/context.rs‎

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -307,17 +307,23 @@ pub fn context_codegen(data: ContextData) -> EmbeddedAssetsResult<TokenStream> {
307307
}
308308
if let Some(version) = &config.version {
309309
plist.insert("CFBundleShortVersionString".into(), version.clone().into());
310-
}
311-
let format =
312-
time::format_description::parse("[year][month][day].[hour][minute][second]").unwrap();
313-
if let Ok(build_number) = time::OffsetDateTime::now_utc().format(&format) {
314-
plist.insert("CFBundleVersion".into(), build_number.into());
310+
plist.insert("CFBundleVersion".into(), version.clone().into());
315311
}
316312
}
317313

314+
let plist_file = out_dir.join("Info.plist");
315+
316+
let mut plist_contents = std::io::BufWriter::new(Vec::new());
318317
info_plist
319-
.to_file_xml(out_dir.join("Info.plist"))
320-
.expect("failed to write Info.plist");
318+
.to_writer_xml(&mut plist_contents)
319+
.expect("failed to serialize plist");
320+
let plist_contents =
321+
String::from_utf8_lossy(&plist_contents.into_inner().unwrap()).into_owned();
322+
323+
if plist_contents != std::fs::read_to_string(&plist_file).unwrap_or_default() {
324+
std::fs::write(&plist_file, &plist_contents).expect("failed to write Info.plist");
325+
}
326+
321327
quote!({
322328
tauri::embed_plist::embed_info_plist!(concat!(std::env!("OUT_DIR"), "/Info.plist"));
323329
})

0 commit comments

Comments
 (0)