Skip to content

Commit

Permalink
fix(cli): pbxproj parser not expecting underlines in build config IDs (
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog authored Sep 27, 2024
1 parent de7414a commit df24cb9
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 14 deletions.
6 changes: 6 additions & 0 deletions .changes/fix-pbxproj-id-parse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"tauri-cli": patch:bug
"@tauri-apps/cli": patch:bug
---

Fixes Xcode pbxproj file parsing not expecting `_` in build configuration IDs.
10 changes: 7 additions & 3 deletions crates/tauri-cli/src/helpers/pbxproj.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub fn parse<P: AsRef<Path>>(path: P) -> crate::Result<Pbxproj> {
if line == "/* End XCBuildConfiguration section */" {
state = State::Idle;
} else if let Some((_identation, token)) = split_at_identation(line) {
let id: String = token.chars().take_while(|c| c.is_alphanumeric()).collect();
let id: String = token.chars().take_while(|c| !c.is_whitespace()).collect();
proj.xc_build_configuration.insert(
id.clone(),
XCBuildConfiguration {
Expand Down Expand Up @@ -316,8 +316,12 @@ mod tests {
let mut pbxproj =
super::parse(fixtures_path.join("project.pbxproj")).expect("failed to parse pbxproj");

pbxproj.set_build_settings("DB0E254D0FD84970B57F6410", "PRODUCT_NAME", "\"Tauri Test\"");
pbxproj.set_build_settings("DB0E254D0FD84970B57F6410", "UNKNOWN", "9283j49238h");
pbxproj.set_build_settings(
"DB_0E254D0FD84970B57F6410",
"PRODUCT_NAME",
"\"Tauri Test\"",
);
pbxproj.set_build_settings("DB_0E254D0FD84970B57F6410", "UNKNOWN", "9283j49238h");

insta::assert_snapshot!("project-modified.pbxproj", pbxproj.serialize());
}
Expand Down
10 changes: 5 additions & 5 deletions crates/tauri-cli/src/mobile/ios/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ pub fn synchronize_project_config(
config: &AppleConfig,
tauri_config: &ConfigHandle,
pbxproj: &mut pbxproj::Pbxproj,
export_options_list: &mut plist::Dictionary,
export_options_plist: &mut plist::Dictionary,
project_config: &ProjectConfig,
debug: bool,
) -> Result<()> {
Expand Down Expand Up @@ -522,7 +522,7 @@ pub fn synchronize_project_config(

if let Some(build_configuration) = build_configuration {
if let Some(style) = build_configuration.get_build_setting("CODE_SIGN_STYLE") {
export_options_list.insert(
export_options_plist.insert(
"signingStyle".to_string(),
style.value.to_lowercase().into(),
);
Expand All @@ -532,7 +532,7 @@ pub fn synchronize_project_config(
.get_build_setting("\"CODE_SIGN_IDENTITY[sdk=iphoneos*]\"")
.or_else(|| build_configuration.get_build_setting("CODE_SIGN_IDENTITY"))
{
export_options_list.insert(
export_options_plist.insert(
"signingCertificate".to_string(),
identity.value.trim_matches('"').into(),
);
Expand All @@ -542,7 +542,7 @@ pub fn synchronize_project_config(
.get_build_setting("\"DEVELOPMENT_TEAM[sdk=iphoneos*]\"")
.or_else(|| build_configuration.get_build_setting("DEVELOPMENT_TEAM"))
{
export_options_list.insert("teamID".to_string(), id.value.trim_matches('"').into());
export_options_plist.insert("teamID".to_string(), id.value.trim_matches('"').into());
}

let profile_uuid = project_config
Expand All @@ -557,7 +557,7 @@ pub fn synchronize_project_config(
if let Some(profile_uuid) = profile_uuid {
let mut provisioning_profiles = plist::Dictionary::new();
provisioning_profiles.insert(config.app().identifier().to_string(), profile_uuid.into());
export_options_list.insert(
export_options_plist.insert(
"provisioningProfiles".to_string(),
provisioning_profiles.into(),
);
Expand Down
4 changes: 2 additions & 2 deletions crates/tauri-cli/tests/fixtures/pbxproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@
};
name = debug;
};
DB0E254D0FD84970B57F6410 /* release */ = {
DB_0E254D0FD84970B57F6410 /* release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
Expand Down Expand Up @@ -454,7 +454,7 @@
isa = XCConfigurationList;
buildConfigurations = (
BF284FE6E7AE0C8DDCCE398B /* debug */,
DB0E254D0FD84970B57F6410 /* release */,
DB_0E254D0FD84970B57F6410 /* release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = debug;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ expression: pbxproj.serialize()
};
name = debug;
};
DB0E254D0FD84970B57F6410 /* release */ = {
DB_0E254D0FD84970B57F6410 /* release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
Expand Down Expand Up @@ -459,7 +459,7 @@ expression: pbxproj.serialize()
isa = XCConfigurationList;
buildConfigurations = (
BF284FE6E7AE0C8DDCCE398B /* debug */,
DB0E254D0FD84970B57F6410 /* release */,
DB_0E254D0FD84970B57F6410 /* release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = debug;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ Pbxproj {
},
],
},
"DB0E254D0FD84970B57F6410": XCBuildConfiguration {
"DB_0E254D0FD84970B57F6410": XCBuildConfiguration {
build_settings: [
BuildSettings {
identation: "\t\t\t\t",
Expand Down Expand Up @@ -894,7 +894,7 @@ Pbxproj {
comments: "/* debug */",
},
BuildConfigurationRef {
id: "DB0E254D0FD84970B57F6410",
id: "DB_0E254D0FD84970B57F6410",
comments: "/* release */",
},
],
Expand Down

0 comments on commit df24cb9

Please sign in to comment.