Skip to content

Commit 937ff98

Browse files
authored
fix: XCArchive upload on macOS ARM only (#2635)
Updates the mobile app command to make sure apple apps aren't uploaded from non-macos ARM, follow up from #2619
1 parent 30c8be3 commit 937ff98

File tree

4 files changed

+14
-8
lines changed

4 files changed

+14
-8
lines changed

src/commands/mobile_app/upload.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,19 @@ use crate::utils::fs::get_sha1_checksums;
2525
use crate::utils::fs::TempDir;
2626
use crate::utils::fs::TempFile;
2727
#[cfg(all(target_os = "macos", target_arch = "aarch64"))]
28-
use crate::utils::mobile_app::{handle_asset_catalogs, ipa_to_xcarchive, is_ipa_file};
29-
use crate::utils::mobile_app::{is_aab_file, is_apk_file, is_apple_app, is_zip_file};
28+
use crate::utils::mobile_app::{
29+
handle_asset_catalogs, ipa_to_xcarchive, is_apple_app, is_ipa_file,
30+
};
31+
use crate::utils::mobile_app::{is_aab_file, is_apk_file, is_zip_file};
3032
use crate::utils::progress::ProgressBar;
3133
use crate::utils::vcs;
3234

3335
pub fn make_command(command: Command) -> Command {
3436
#[cfg(all(target_os = "macos", target_arch = "aarch64"))]
3537
const HELP_TEXT: &str = "The path to the mobile app files to upload. Supported files include Apk, Aab, XCArchive, and IPA.";
3638
#[cfg(not(all(target_os = "macos", target_arch = "aarch64")))]
37-
const HELP_TEXT: &str = "The path to the mobile app files to upload. Supported files include Apk, Aab, and XCArchive.";
39+
const HELP_TEXT: &str =
40+
"The path to the mobile app files to upload. Supported files include Apk, and Aab.";
3841
command
3942
.about("[EXPERIMENTAL] Upload mobile app files to a project.")
4043
.org_arg()
@@ -201,6 +204,7 @@ fn handle_file(path: &Path, byteview: &ByteView) -> Result<TempFile> {
201204
fn validate_is_mobile_app(path: &Path, bytes: &[u8]) -> Result<()> {
202205
debug!("Validating mobile app format for: {}", path.display());
203206

207+
#[cfg(all(target_os = "macos", target_arch = "aarch64"))]
204208
if is_apple_app(path) {
205209
debug!("Detected XCArchive directory");
206210
return Ok(());
@@ -234,7 +238,7 @@ fn validate_is_mobile_app(path: &Path, bytes: &[u8]) -> Result<()> {
234238
#[cfg(all(target_os = "macos", target_arch = "aarch64"))]
235239
let format_list = "APK, AAB, XCArchive, or IPA";
236240
#[cfg(not(all(target_os = "macos", target_arch = "aarch64")))]
237-
let format_list = "APK, AAB, or XCArchive";
241+
let format_list = "APK, or AAB";
238242

239243
Err(anyhow!(
240244
"File is not a recognized mobile app format ({format_list}): {}",

src/utils/mobile_app/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ mod validation;
66

77
#[cfg(all(target_os = "macos", target_arch = "aarch64"))]
88
pub use self::apple::{handle_asset_catalogs, ipa_to_xcarchive};
9+
pub use self::validation::{is_aab_file, is_apk_file, is_zip_file};
910
#[cfg(all(target_os = "macos", target_arch = "aarch64"))]
10-
pub use self::validation::is_ipa_file;
11-
pub use self::validation::{is_aab_file, is_apk_file, is_apple_app, is_zip_file};
11+
pub use self::validation::{is_apple_app, is_ipa_file};

src/utils/mobile_app/validation.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#[cfg(all(target_os = "macos", target_arch = "aarch64"))]
12
use std::path::Path;
23

34
use anyhow::Result;
@@ -51,6 +52,7 @@ pub fn is_ipa_file(bytes: &[u8]) -> Result<bool> {
5152
Ok(is_ipa)
5253
}
5354

55+
#[cfg(all(target_os = "macos", target_arch = "aarch64"))]
5456
pub fn is_xcarchive_directory<P>(path: P) -> bool
5557
where
5658
P: AsRef<Path>,
@@ -65,6 +67,7 @@ where
6567
}
6668

6769
/// A path is an Apple app if it points to an xarchive directory
70+
#[cfg(all(target_os = "macos", target_arch = "aarch64"))]
6871
pub fn is_apple_app(path: &Path) -> bool {
6972
path.is_dir() && is_xcarchive_directory(path)
7073
}

tests/integration/_cases/mobile_app/mobile_app-upload-help-not-macos.trycmd

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ $ sentry-cli mobile-app upload --help
66
Usage: sentry-cli[EXE] mobile-app upload [OPTIONS] <PATH>...
77

88
Arguments:
9-
<PATH>... The path to the mobile app files to upload. Supported files include Apk, Aab, and
10-
XCArchive.
9+
<PATH>... The path to the mobile app files to upload. Supported files include Apk, and Aab.
1110

1211
Options:
1312
-o, --org <ORG>

0 commit comments

Comments
 (0)