Skip to content

Commit

Permalink
fix: rebuild every time because of Info.plist changes tauri-apps#7614
Browse files Browse the repository at this point in the history
  • Loading branch information
olexiyb committed May 25, 2024
1 parent 51b5d58 commit b01be54
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions core/tauri-codegen/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,17 +325,21 @@ pub fn context_codegen(data: ContextData) -> Result<TokenStream, EmbeddedAssetsE
}
if let Some(version) = &config.version {
plist.insert("CFBundleShortVersionString".into(), version.clone().into());
}
let format =
time::format_description::parse("[year][month][day].[hour][minute][second]").unwrap();
if let Ok(build_number) = time::OffsetDateTime::now_utc().format(&format) {
plist.insert("CFBundleVersion".into(), build_number.into());
plist.insert("CFBundleVersion".into(), version.clone().into());
}
}

info_plist
.to_file_xml(out_dir.join("Info.plist"))
.expect("failed to write Info.plist");

let plist_file = out_dir.join("Info.plist");
let old = if plist_file.exists() {
plist::Value::from_file(&plist_file).expect("failed to read old Info.plist")
} else {
plist::Value::Dictionary(Default::default())
};
let old = serde_json::to_string(&old).unwrap();
let n = serde_json::to_string(&info_plist).unwrap();
if old.ne(&n) {
info_plist.to_file_xml(plist_file).expect("failed to write Info.plist");
}
quote!({
tauri::embed_plist::embed_info_plist!(concat!(std::env!("OUT_DIR"), "/Info.plist"));
})
Expand Down

0 comments on commit b01be54

Please sign in to comment.