Skip to content
This repository was archived by the owner on Oct 23, 2026. It is now read-only.

feat(build): support iOS XCArchive and IPA upload - #1185

Merged
BYK merged 3 commits into
mainfrom
byk/feat/build-upload-ios
Jul 3, 2026
Merged

BYK merged 3 commits into
mainfrom
byk/feat/build-upload-ios

Conversation

@BYK

@BYK BYK commented Jul 3, 2026

Copy link
Copy Markdown
Member

Extends build upload (Android APK/AAB, PRs #1172/#1174) to iOS — XCArchive and IPA.

What

  • XCArchive (a directory): zipped under its basename (MyApp.xcarchive/…) + a root .sentry-cli-metadata.txt, mirroring the legacy normalize_directory.
  • IPA (a file): converted in-memory to an XCArchive layout — Payload/<app>.app/… → archive.xcarchive/Products/Applications/<app>.app/… plus a generated archive.xcarchive/Info.plist — mirroring ipa_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_catalogs parses Assets.car via native macOS CoreUI (apple_catalog_parsing). Per the agreed scope we skip .car parsing, and with that removed the entire iOS path (ipa_to_xcarchive is pure zip + a static plist string; normalize_directory is a plain directory walk) is portable — so iOS upload ships on all platforms, no Apple-Silicon gate.

Documented limitations

  • No Assets.car asset-catalog parsing → server sees the raw .car, not a per-image breakdown.
  • Directory symlinks are followed and stored as target content (not preserved as symlink entries); Unix permissions are not preserved (a zipSync limitation). iOS .app bundles are typically flat, so this is rarely material.
  • In-memory normalization (same as the Android path) — a very large XCArchive with dSYMs could hit Node's ~2 GiB Buffer cap; streaming-to-temp-file is a noted follow-up.

Tests

Lib: XCArchive dir → zip structure + determinism; IPA → XCArchive structure + generated Info.plist + Assets.car passed through verbatim; extractIpaAppName for 0/1/≥2 .app. Command: XCArchive directory + IPA both reach uploadBuild; obsolete "not supported" cases replaced.

typecheck, lint, check:deps, check:fragments pass; 44 build tests pass.

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.
@github-actions

github-actions Bot commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://cli.sentry.dev/_preview/pr-1185/

Built to branch gh-pages at 2026-07-03 08:40 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

Comment thread src/lib/build/index.ts Resolved
Comment thread src/lib/build/index.ts Resolved
@github-actions

github-actions Bot commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

Codecov Results 📊

✅ Patch coverage is 96.59%. Project has 5190 uncovered lines.
✅ Project coverage is 81.77%. Comparing base (base) to head (head).

Files with missing lines (1)
File Patch % Lines
src/lib/build/index.ts 96.25% ⚠️ 3 Missing and 5 partials
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       +11

Generated 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.
@BYK

BYK commented Jul 3, 2026

Copy link
Copy Markdown
Member Author

Self-review (subagent-assisted) + fixes

H1 (guardrail/parity, fixed): the directory path zipped and uploaded any directory with no validation — a stray sentry build upload ./ (or ./build/) would have swept up source, .git/, node_modules/, and .env secrets and shipped them to Sentry. Now validateXcarchiveDirectory (ported from the Rust validate_xcarchive_directory) requires a root Info.plist, a Products/ directory, and ≥1 .app (each with its own Info.plist) before anything is zipped.

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 ZipAttributes (os/attrs) can carry Unix mode bits, so I now preserve symlinks as symlink entries (S_IFLNK + target string) and Unix permissions, matching Rust. Verified by round-tripping through the real unzip: X -> Versions/Current/X stays a symlink and run.sh extracts as -rwxr-xr-x.

Also: L1 — removed the dead format === "xcarchive" branch (a file is never an XCArchive); L2 — skip .. path-traversal entries when converting an IPA.

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 Info.plist, the extractIpaAppName 2-slash rule, the dropped Apple-Silicon gate (enabled by skipping .car parsing — documented), and fail-non-zero-on-any-partial-failure. Remaining documented limitations: no .car asset-catalog parsing (M2) and in-memory normalization (M1) — streaming is a noted follow-up.

Comment thread src/lib/build/index.ts Resolved
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.

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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.

Comment thread src/lib/build/index.ts
const attrs = ((mode & 0xff_ff) << 16) >>> 0;
entries.push({ relPath, content, attrs });
}
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 4d05c07. Configure here.

Comment thread src/lib/build/index.ts
Comment on lines +198 to +200
continue;
}
const full = join(dir, dirent.name);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@BYK
BYK merged commit 591f1bb into main Jul 3, 2026
32 checks passed
@BYK
BYK deleted the byk/feat/build-upload-ios branch July 3, 2026 08:51
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant