diff --git a/CHANGELOG.md b/CHANGELOG.md index 982b5375fe..afc56191c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Fixes - Accept ProGuard mapping files without line information instead of rejecting them ([#3192](https://github.com/getsentry/sentry-cli/pull/3192)). +- Improve error message when uploading `.xcarchive` or `.ipa` files on non-Apple Silicon Macs ([#3211](https://github.com/getsentry/sentry-cli/pull/3211)). ### Experimental Feature 🧑‍🔬 (internal-only) diff --git a/src/commands/build/upload.rs b/src/commands/build/upload.rs index 96701b74e5..27b4b03cca 100644 --- a/src/commands/build/upload.rs +++ b/src/commands/build/upload.rs @@ -209,6 +209,20 @@ pub fn execute(matches: &ArgMatches) -> Result<()> { return Err(anyhow!("Path does not exist: {}", path.display())); } + // On non-Apple Silicon, reject xcarchive/IPA early before trying to + // open the path as a file (xcarchive is a directory, so ByteView::open + // would fail with a confusing I/O error). + #[cfg(not(all(target_os = "macos", target_arch = "aarch64")))] + { + let ext = path.extension().and_then(|e| e.to_str()).unwrap_or(""); + if ext.eq_ignore_ascii_case("xcarchive") || ext.eq_ignore_ascii_case("ipa") { + return Err(anyhow!( + "Uploading XCArchive and IPA files requires an Apple Silicon Mac: {}", + path.display() + )); + } + } + let byteview = ByteView::open(path)?; debug!("Loaded file with {} bytes", byteview.len()); @@ -542,6 +556,7 @@ fn validate_is_supported_build(path: &Path, bytes: &[u8]) -> Result<()> { } debug!("File format validation failed"); + #[cfg(all(target_os = "macos", target_arch = "aarch64"))] let format_list = "APK, AAB, XCArchive, or IPA"; #[cfg(not(all(target_os = "macos", target_arch = "aarch64")))] diff --git a/tests/integration/_cases/build/build-upload-ipa-not-arm64.trycmd b/tests/integration/_cases/build/build-upload-ipa-not-arm64.trycmd new file mode 100644 index 0000000000..8975f3d9d1 --- /dev/null +++ b/tests/integration/_cases/build/build-upload-ipa-not-arm64.trycmd @@ -0,0 +1,9 @@ +``` +$ sentry-cli build upload tests/integration/_fixtures/build/ipa.ipa +? failed +error: Uploading XCArchive and IPA files requires an Apple Silicon Mac: tests/integration/_fixtures/build/ipa.ipa + +Add --log-level=[info|debug] or export SENTRY_LOG_LEVEL=[info|debug] to see more output. +Please attach the full debug log to all bug reports. + +``` diff --git a/tests/integration/build/upload.rs b/tests/integration/build/upload.rs index 94c2dfd294..3a07ddb4b6 100644 --- a/tests/integration/build/upload.rs +++ b/tests/integration/build/upload.rs @@ -26,6 +26,14 @@ fn command_build_upload_no_path() { TestManager::new().register_trycmd_test("build/build-upload-no-path.trycmd"); } +#[cfg(not(all(target_os = "macos", target_arch = "aarch64")))] +#[test] +fn command_build_upload_ipa_not_arm64() { + TestManager::new() + .register_trycmd_test("build/build-upload-ipa-not-arm64.trycmd") + .with_default_token(); +} + #[test] fn command_build_upload_invalid_aab() { TestManager::new()