feat(xcframework): embed .dSYM bundles via --debug-symbols#103
Open
pblazej wants to merge 2 commits into
Open
Conversation
Adds a --debug-symbols flag to `cargo swift package`. When set, cargo-swift locates the per-arch .dSYM Cargo emits at target/<arch>/<mode>/deps/lib<name>.dylib.dSYM (requires the user's Cargo profile to enable debug info — typically debug = "limited" + split-debuginfo = "packed" on macOS), then for each xcframework slice: - single-arch slices reuse the per-arch dSYM, - universal slices get a fresh dSYM whose DWARF Mach-O is the lipo-combined fat binary of the per-arch DWARFs (UUIDs preserved per arch). The staged bundle is renamed to <framework_name>.framework.dSYM and the inner DWARF binary is renamed to <framework_name> so xcodebuild's -create-xcframework -debug-symbols drops it into <slice>/dSYMs/ with the canonical name Xcode and App Store Connect expect. E2E test (debug-symbols.swift) creates a cdylib project, enables the dSYM-producing profile knobs, builds with --debug-symbols, then asserts every slice has a dSYMs/<fw>.framework.dSYM bundle whose UUIDs are a superset of the framework binary's UUIDs (so lldb can symbolicate at runtime). Wired into the end-to-end.yml matrix. If --debug-symbols is passed without dSYMs on disk, the build fails with a clear error pointing at the profile knobs to enable, rather than silently producing a symbol-less xcframework.
cargo's dsymutil emits the dSYM Info.plist with CFBundleIdentifier "com.apple.xcode.dsym.<lib>.dylib" because it sees the raw .dylib build artifact. Xcode's own archive-built frameworks land at "com.apple.xcode.dsym.<framework_name>.framework", and crash- reporter vendors (Sentry, Crashlytics, Bugsnag) match on that form. Symbolication itself keys on Mach-O LC_UUID, so the identifier is cosmetic — but it's a visible mismatch from what consumers expect. Rewrite the staged Info.plist with plutil after copying the dSYM bundle. plutil ships with every macOS install, no extra crate. Extend debug-symbols.swift to assert both the new identifier and CFBundlePackageType=dSYM.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
--debug-symbolsflag tocargo swift packagethat embeds.dSYMbundles into thegenerated xcframework, so crash reports against a release (stripped) dynamic framework can be
symbolicated.
.dSYMCargo emits; universalslices get a fresh
.dSYMwhose DWARF Mach-O is thelipo-combined fat binary of theper-arch DWARFs (per-arch UUIDs preserved). Each is renamed to
<framework>.framework.dSYMso
xcodebuild -create-xcframework -debug-symbolsdrops it into<slice>/dSYMs/under thename Xcode and App Store Connect expect.
Info.plistCFBundleIdentifierfrom dsymutil's
com.apple.xcode.dsym.<lib>.dylibto the…<framework>.frameworkform thatXcode-built frameworks use and crash-reporter vendors (Sentry, Crashlytics, Bugsnag) match
on. Done with
plutil(ships with macOS, no new crate).Requires the consuming Cargo profile to actually emit debug info (e.g.
debug = "limited"+split-debuginfo = "packed"on macOS).Testing
New
testing/end-to-end/debug-symbols.swift, wired into theend-to-end.ymlmatrix: builds acdylib with the dSYM-producing profile knobs and
--debug-symbols, then asserts every slicehas a
dSYMs/<fw>.framework.dSYMwhose UUIDs are a superset of the framework binary's UUIDs(so lldb can symbolicate at runtime), plus the rewritten identifier and
CFBundlePackageType=dSYM.