Repository navigation
feat(build): support iOS XCArchive and IPA upload - #1185
Conversation
Extend `build upload` to iOS. An XCArchive (a directory) is zipped under its basename; an IPA is converted in-memory to an XCArchive layout (Payload/<app>.app → archive.xcarchive/Products/Applications/<app>.app + a generated Info.plist), mirroring the legacy CLI's normalize_directory / ipa_to_xcarchive. Both use STORE + a fixed mtime for deterministic chunk dedup. Unlike the legacy CLI, iOS is NOT gated to Apple Silicon: the only native dependency was Assets.car parsing (macOS CoreUI), which is intentionally skipped (documented) — so iOS upload ships cross-platform. Documented gaps: no .car asset-catalog parsing; symlinks followed as content (not preserved as symlink entries); Unix permissions not preserved (zipSync limitation); in-memory normalization (a very large XCArchive with dSYMs could hit Node's ~2 GiB Buffer cap — streaming is a follow-up). - src/lib/build/index.ts: normalizeBuildDirectory, normalizeIpa, extractIpaAppName. - src/commands/build/upload.ts: directory → XCArchive; ipa → normalizeIpa. - Tests: dir/IPA normalization structure + Info.plist + app-name 0/1/≥2; command XCArchive + IPA upload paths.
|
Codecov Results 📊✅ Patch coverage is 96.59%. Project has 5190 uncovered lines. Files with missing lines (1)
Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 81.66% 81.77% +0.11%
==========================================
Files 410 410 —
Lines 28385 28467 +82
Branches 18457 18497 +40
==========================================
+ Hits 23178 23277 +99
- Misses 5207 5190 -17
- Partials 1896 1907 +11Generated by Codecov Action |
- H1 (guardrail/parity): validate a directory is a real XCArchive before zipping — require a root Info.plist, a Products/ dir, and ≥1 .app (each with its own Info.plist). Prevents a stray `sentry build upload ./` from sweeping up source, .git/, or .env secrets. Ports validate_xcarchive_directory. - H2/M3 (size-analysis correctness): preserve symlinks as symlink entries (their target string + S_IFLNK) and Unix permissions, via ZIP external attributes (os=3), instead of following symlinks (which duplicated framework binaries and corrupted the size metric). A custom walk replaces walkFiles for this fidelity. Verified round-trip through the real `unzip`. - L1: drop the dead `format === "xcarchive"` branch (a file is never an XCArchive). - L2: skip path-traversal (`..`) entries when converting an IPA. - Tests: non-XCArchive directory rejection, XCArchive validation cases, symlink preservation, nested-framework IPA remap, IPA traversal guard + determinism. - Docs: correct the fragment — symlinks/perms are now preserved.
Self-review (subagent-assisted) + fixesH1 (guardrail/parity, fixed): the directory path zipped and uploaded any directory with no validation — a stray H2 + M3 (size-analysis correctness, fixed): I was following symlinks and storing their target content, which duplicates framework/dSYM binaries and restructures paths — corrupting the exact size metric this command measures (the Rust CLI warns about this explicitly). fflate's Also: L1 — removed the dead Tests added: non-XCArchive directory rejection, XCArchive validation cases, symlink preservation, nested-framework IPA remap, IPA traversal guard, IPA determinism. The review also confirmed as faithful/deliberate: the IPA→XCArchive remap and byte-identical |
Address bot review on PR #1185: - normalizeIpa now sorts entries by path (like normalizeBuildDirectory) so the output depends only on contents — restoring deterministic bytes / chunk dedup regardless of the IPA's central-directory order. - normalizeIpa now includes only the identified app's entries (Payload/<app>.app/), so a stray second .app bundle can't be uploaded and skew size analysis. - collectArchiveEntries now checks isSymbolicLink() before isDirectory() — a no-op for correct d_type (a symlink-to-dir already reports isDirectory()=false, verified by round-trip), but clearer and defensive. - Test: only the identified app's entries are bundled.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 4d05c07. Configure here.
| const attrs = ((mode & 0xff_ff) << 16) >>> 0; | ||
| entries.push({ relPath, content, attrs }); | ||
| } | ||
| }; |
There was a problem hiding this comment.
Validation follows symlinked Products
High Severity
validateXcarchiveDirectory discovers .app bundles via findAppBundles and statSync/readdirSync on Products/, which follow directory symlinks, while collectArchiveEntries stores symlink entries without walking their targets. A valid-looking archive whose Products/ is a symlink can pass validation yet produce an upload missing the app tree.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 4d05c07. Configure here.
| continue; | ||
| } | ||
| const full = join(dir, dirent.name); |
There was a problem hiding this comment.
Bug: The findAppBundles function incorrectly skips .app bundles that are symbolic links because it only checks dirent.isDirectory(), causing validation to fail for valid XCArchives in some CI environments.
Severity: MEDIUM
Suggested Fix
In findAppBundles, modify the loop that identifies app bundles. Before checking dirent.isDirectory(), add a check for dirent.isSymbolicLink(). If an entry is a symlink, you will need to resolve its path and verify that the target is a directory. This will ensure that symlinked .app bundles are correctly identified.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: src/lib/build/index.ts#L198-L200
Potential issue: The `findAppBundles` function iterates through directory entries and
uses `dirent.isDirectory()` to identify `.app` bundles. This check returns `false` for
symbolic links. In CI/CD environments where an XCArchive's
`Products/Applications/MyApp.app` is a symlink to a real directory, `findAppBundles`
will fail to identify it. This causes the `validateXcarchiveDirectory` function to
receive an empty array and incorrectly throw an `"Invalid XCArchive: no .app bundles
found under Products/"` error, rejecting a structurally valid archive.


Extends
build upload(Android APK/AAB, PRs #1172/#1174) to iOS — XCArchive and IPA.What
MyApp.xcarchive/…) + a root.sentry-cli-metadata.txt, mirroring the legacynormalize_directory.Payload/<app>.app/…→archive.xcarchive/Products/Applications/<app>.app/…plus a generatedarchive.xcarchive/Info.plist— mirroringipa_to_xcarchive+normalize_directory. Requires exactly one.app.Both use STORE + a fixed mtime so identical inputs produce identical bytes (chunk dedup on re-upload).
Cross-platform (intentional divergence from the Rust CLI)
The legacy CLI gated iOS to Apple Silicon solely because
handle_asset_catalogsparsesAssets.carvia native macOS CoreUI (apple_catalog_parsing). Per the agreed scope we skip.carparsing, and with that removed the entire iOS path (ipa_to_xcarchiveis pure zip + a static plist string;normalize_directoryis a plain directory walk) is portable — so iOS upload ships on all platforms, no Apple-Silicon gate.Documented limitations
Assets.carasset-catalog parsing → server sees the raw.car, not a per-image breakdown.zipSynclimitation). iOS.appbundles are typically flat, so this is rarely material.Tests
Lib: XCArchive dir → zip structure + determinism; IPA → XCArchive structure + generated Info.plist +
Assets.carpassed through verbatim;extractIpaAppNamefor 0/1/≥2.app. Command: XCArchive directory + IPA both reachuploadBuild; obsolete "not supported" cases replaced.typecheck,lint,check:deps,check:fragmentspass; 44 build tests pass.