Skip to content

fix: Match Xcode linking in SwiftPM frameworks - #9851

Draft
denrase wants to merge 2 commits into
mainfrom
denrase/fix/spm-binary-linking
Draft

denrase wants to merge 2 commits into
mainfrom
denrase/fix/spm-binary-linking

Conversation

@denrase

@denrase denrase commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator

📜 Description

The SwiftPM-built dynamic frameworks linked differently from the Xcode-built ones:

  • System frameworks such as UIKit, SwiftUI and WebKit were weak-linked. Xcode links them strongly.
  • The @loader_path/Frameworks rpath was missing.

scripts/build-dynamic-framework.sh now uses the same link inputs as the Xcode project, so both producers emit the same dylib and rpath load commands.

This also changes the released SentryObjC-Dynamic.xcframework, which is linked by the same script.

💡 Motivation and Context

Part of #9660. Customers should be able to swap the Xcode-built binary for the SwiftPM-built one without changing their setup.

It also unblocks no-UI variants (#9659): the old script always linked UIKit, SwiftUI and AppKit.

Loading tests for app extensions and embedding frameworks are still open on #9660.

💚 How did you test it?

  • Built all 10 SDK slices with Xcode and with SwiftPM. The load commands are identical for every slice and architecture.
  • No exported symbols or Objective-C classes are lost compared with the old script, for Sentry and SentryObjC.
  • SPM-Dynamic and SPM-ObjC-Dynamic pass against the new XCFramework on macOS.
  • Extended scripts/test-build-dynamic-framework.sh. It failed before the fix.

make analyze fails locally while resolving packages, also on a clean main.

📝 Checklist

You have to check all boxes before merging:

  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.
  • Public API changes (sdk_api.json, sdk_api_objc.json) reviewed by another Mobile SDK team member or implemented according to the develop docs spec.
  • If I added a new public API, I also added it to the SentryObjC wrapper.

The relinker weak-linked a fixed list of system frameworks and
set only the @executable_path/Frameworks rpath, so its load
commands differed from the Xcode-built framework.

Use the Xcode project's link inputs instead: name only
Foundation, CoreData and, where Xcode links it,
SystemConfiguration, and let autolinking add the rest. Add the
@loader_path/Frameworks rpath and Xcode's dead-stripping, and
set SDKROOT so the link no longer warns about the sysroot.

Refs #9660
@denrase denrase self-assigned this Nov 30, 2026
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Nov 30, 2026
@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

PR risk: medium

For commit dc7faa3.

Main concerns: dependencies customers inherit, reach, public contract.

Rules that block low also fired:

  • R6: build or release configuration changed: scripts/build-dynamic-framework.sh, scripts/test-build-dynamic-framework.sh

This label is a hint for reviewers, not an approval.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant