fix(xcode): Plist vars are always expanded
@@ -249,7 +249,7 @@ impl InfoPlist {
vars: &HashMap<String, String>,
) -> Result<InfoPlist> {
// do we want to preprocess the plist file?
- if vars.get("INFOPLIST_PREPROCESS").map(String::as_str) == Some("YES") {
+ let plist = if vars.get("INFOPLIST_PREPROCESS").map(String::as_str) == Some("YES") {
let mut c = process::Command::new("cc");
c.arg("-xc").arg("-P").arg("-E");
if let Some(defs) = vars.get("INFOPLIST_OTHER_PREPROCESSOR_FLAGS") {
@@ -264,17 +264,8 @@ impl InfoPlist {
}
c.arg(path.as_ref());
let p = c.output()?;
- let mut plist = InfoPlist::from_reader(&mut Cursor::new(&p.stdout[..]))?;
-
- // expand xcodevars here
- plist.name = expand_xcodevars(&plist.name, vars);
- plist.bundle_id = expand_xcodevars(&plist.bundle_id, vars);
- plist.version = expand_xcodevars(&plist.version, vars);
- plist.build = expand_xcodevars(&plist.build, vars);
-
- return Ok(plist);
- }
-
+ InfoPlist::from_reader(&mut Cursor::new(&p.stdout[..])).map_err(|e| e)
+ } else {
InfoPlist::from_path(path).or_else(|err| {
/*
This is sort of an edge-case, as XCode is not producing an `Info.plist` file
@@ -311,6 +302,22 @@ impl InfoPlist {
*/
InfoPlist::from_env_vars(vars).map_err(|e| e.context(err))
})
+ };
+
+ if let Ok(raw) = plist {
+ let name = expand_xcodevars(&raw.name, vars);
+ let bundle_id = expand_xcodevars(&raw.bundle_id, vars);
+ let version = expand_xcodevars(&raw.version, vars);
+ let build = expand_xcodevars(&raw.build, vars);
+ return Ok(InfoPlist {
+ name,
+ bundle_id,
+ version,
+ build,
+ });
+ } else {
+ return plist;
+ }
}
/// Loads an info plist from provided environment variables list
