Skip to content

Commit 956b4fd

Browse files
authored
fix(cli): export method on Xcode < 15.4, closes #13818 (#14106)
see fastlane/fastlane#22028 for additional context
1 parent 07e134f commit 956b4fd

File tree

4 files changed

+61
-2
lines changed

4 files changed

+61
-2
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"tauri-cli": patch:bug
3+
"@tauri-apps/cli": patch:bug
4+
---
5+
6+
Use the correct export method on Xcode < 15.4.

crates/tauri-cli/src/info/env_system.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,22 @@ fn is_xcode_command_line_tools_installed() -> bool {
175175
.map(|o| o.status.success())
176176
.unwrap_or(false)
177177
}
178+
179+
#[cfg(target_os = "macos")]
180+
pub fn xcode_version() -> Option<String> {
181+
Command::new("xcodebuild")
182+
.arg("-version")
183+
.output()
184+
.ok()
185+
.map(|o| String::from_utf8_lossy(&o.stdout).into_owned())
186+
.and_then(|s| {
187+
s.split('\n')
188+
.filter_map(|line| line.strip_prefix("Xcode "))
189+
.next()
190+
.map(ToString::to_string)
191+
})
192+
}
193+
178194
fn de_and_session() -> String {
179195
#[cfg(any(
180196
target_os = "linux",
@@ -319,5 +335,11 @@ pub fn items() -> Vec<SectionItem> {
319335
}.into()
320336
},
321337
),
338+
#[cfg(target_os = "macos")]
339+
SectionItem::new().action(|| {
340+
xcode_version().map(|v| (format!("Xcode: {v}"), Status::Success)).unwrap_or_else(|| {
341+
(format!("Xcode: {}", "not installed!".red()), Status::Error)
342+
}).into()
343+
}),
322344
]
323345
}

crates/tauri-cli/src/info/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use std::fmt::{self, Display, Formatter};
1515
mod app;
1616
mod env_nodejs;
1717
mod env_rust;
18-
mod env_system;
18+
pub mod env_system;
1919
#[cfg(target_os = "macos")]
2020
mod ios;
2121
mod packages_nodejs;

crates/tauri-cli/src/mobile/ios/build.rs

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,17 @@ pub enum ExportMethod {
102102
Debugging,
103103
}
104104

105+
impl ExportMethod {
106+
/// Xcode 15.4 deprecated these names (in this case we should use the Display impl).
107+
pub fn pre_xcode_15_4_name(&self) -> String {
108+
match self {
109+
Self::AppStoreConnect => "app-store".to_string(),
110+
Self::ReleaseTesting => "ad-hoc".to_string(),
111+
Self::Debugging => "development".to_string(),
112+
}
113+
}
114+
}
115+
105116
impl std::fmt::Display for ExportMethod {
106117
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
107118
match self {
@@ -215,7 +226,27 @@ pub fn command(options: Options, noise_level: NoiseLevel) -> Result<()> {
215226

216227
let mut export_options_plist = plist::Dictionary::new();
217228
if let Some(method) = options.export_method {
218-
export_options_plist.insert("method".to_string(), method.to_string().into());
229+
let xcode_version =
230+
crate::info::env_system::xcode_version().context("failed to determine Xcode version")?;
231+
let mut iter = xcode_version.split('.');
232+
let major = iter.next().context(format!(
233+
"failed to parse Xcode version `{xcode_version}` as semver"
234+
))?;
235+
let minor = iter.next().context(format!(
236+
"failed to parse Xcode version `{xcode_version}` as semver"
237+
))?;
238+
let major = major.parse::<u64>().context(format!(
239+
"failed to parse Xcode version `{xcode_version}` as semver: major is not a number"
240+
))?;
241+
let minor = minor.parse::<u64>().context(format!(
242+
"failed to parse Xcode version `{xcode_version}` as semver: minor is not a number"
243+
))?;
244+
245+
if major < 15 || (major == 15 && minor < 4) {
246+
export_options_plist.insert("method".to_string(), method.pre_xcode_15_4_name().into());
247+
} else {
248+
export_options_plist.insert("method".to_string(), method.to_string().into());
249+
}
219250
}
220251

221252
let (keychain, provisioning_profile) = super::signing_from_env()?;

0 commit comments

Comments
 (0)