-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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 #9878
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice catch, can you clean this up so it only serializes the plist once?
diff --git a/core/tauri-codegen/src/context.rs b/core/tauri-codegen/src/context.rs
index 59e9a78ef..ace1e345a 100644
--- a/core/tauri-codegen/src/context.rs
+++ b/core/tauri-codegen/src/context.rs
@@ -4,6 +4,7 @@
use std::collections::BTreeMap;
use std::convert::identity;
+use std::io::BufWriter;
use std::path::{Path, PathBuf};
use std::{ffi::OsStr, str::FromStr};
@@ -328,18 +329,20 @@ pub fn context_codegen(data: ContextData) -> Result<TokenStream, EmbeddedAssetsE
plist.insert("CFBundleVersion".into(), version.clone().into());
}
}
-
+
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");
+
+ let mut plist_contents = BufWriter::new(Vec::new());
+ info_plist
+ .to_writer_xml(&mut plist_contents)
+ .expect("failed to serialize plist");
+ let plist_contents =
+ String::from_utf8_lossy(&plist_contents.into_inner().unwrap()).into_owned();
+
+ if plist_contents != std::fs::read_to_string(&plist_file).unwrap_or_default() {
+ std::fs::write(&plist_file, &plist_contents).expect("failed to write Info.plist");
}
+
quote!({
tauri::embed_plist::embed_info_plist!(concat!(std::env!("OUT_DIR"), "/Info.plist"));
})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
must fix clippy and also add a change file in the .changes
folder:
.changes/fix-build-script-rerun-macos.md
---
"tauri-codegen": patch:bug
---
Fixes Info.plist rewriting always triggering build to rerun.
Co-authored-by: Lucas Fernandes Nogueira <[email protected]>
Co-authored-by: Lucas Fernandes Nogueira <[email protected]>
According to macos documentation
Current logic of the build prepare Info.plist with added timestamp at the end, this cause rebuild each restart even if not needed. Because
You can include more integers but the system ignores them
it does not make any sense to add timestampI also have to check Info.plist content from previous build with new build. If no changes just skip the write
This should solve #7614