Skip to content

WIP: feat(ios): opt-in consumption of sentry-cocoa via Swift Package Manager#6182

Draft
alwx wants to merge 1 commit into
mainfrom
alwx/feat/spm-sentry-cocoa
Draft

WIP: feat(ios): opt-in consumption of sentry-cocoa via Swift Package Manager#6182
alwx wants to merge 1 commit into
mainfrom
alwx/feat/spm-sentry-cocoa

Conversation

@alwx
Copy link
Copy Markdown
Contributor

@alwx alwx commented May 18, 2026

Adds a new opt-in path in RNSentry.podspec: when SENTRY_USE_SPM=1 is set in the environment before pod install, RNSentry pulls Sentry from the sentry-cocoa SPM package (as a binary xcframework) instead of from the Sentry CocoaPods source build.

This is the first step of the broader SPM migration tracked at #5780. It unblocks experimentation with binary-framework consumption of sentry-cocoa while keeping CocoaPods as the production default.

BUT those things need to be done before we will be able to migrate:

  1. The Sentry xcframework in sentry-cocoa 9.13.0 and earlier is missing the SentrySessionReplayHybridSDK symbol due to a packaging bug (fix(replay): correct file type for SentrySessionReplayHybridSDK.m in pbxproj sentry-cocoa#7911). Apps that use Session Replay will fail to link until that fix ships in a sentry-cocoa release. Apps not using Session Replay are unaffected.
  2. SentrySwizzle.h must be imported via framework-style (<Sentry/...>) rather than quote-style when the xcframework is the consumption path — already handled by #6181

Verified locally:

  • Default pod install (no env var) — ** BUILD SUCCEEDED ** on the RN sample, identical to the pre-change state.
  • SENTRY_USE_SPM=1 pod install — Sentry no longer in Podfile.lock, XCRemoteSwiftPackageReference "sentry-cocoa" injected into the Xcode project, [SPM] log lines confirm the helper ran correctly.

Refs: #5780, #6170

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

💡 Motivation and Context

💚 How did you test it?

📝 Checklist

  • I added tests to verify 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.
  • All tests passing
  • No breaking changes

🔮 Next steps

Adds a new opt-in path in RNSentry.podspec: when `SENTRY_USE_SPM=1` is set
in the environment before `pod install`, RNSentry pulls `Sentry` from the
sentry-cocoa SPM package (as a binary xcframework) instead of from the
Sentry CocoaPods source build.

Default behavior is unchanged. Existing users on any React Native version
keep their current CocoaPods-based consumption with no action required.

The opt-in path requires React Native >= 0.75 because it uses the
`SPMManager` singleton defined in `react-native/scripts/cocoapods/spm.rb`,
which is loaded transitively from the Podfile via `react_native_pods.rb`.

This is the first step of the broader SPM migration tracked at #5780. It
unblocks experimentation with binary-framework consumption of sentry-cocoa
while keeping CocoaPods as the production default.

Two known caveats for users opting in today:

1. The Sentry xcframework in sentry-cocoa 9.13.0 and earlier is missing the
   `SentrySessionReplayHybridSDK` symbol due to a packaging bug
   (getsentry/sentry-cocoa#7911). Apps that use Session Replay will fail to
   link until that fix ships in a sentry-cocoa release. Apps not using
   Session Replay are unaffected.
2. `SentrySwizzle.h` must be imported via framework-style (`<Sentry/...>`)
   rather than quote-style when the xcframework is the consumption path —
   already handled by #6175 (in this same release).

Verified locally:
- Default `pod install` (no env var) — `** BUILD SUCCEEDED **` on the
  RN sample, identical to the pre-change state.
- `SENTRY_USE_SPM=1 pod install` — Sentry no longer in Podfile.lock,
  `XCRemoteSwiftPackageReference "sentry-cocoa"` injected into the Xcode
  project, [SPM] log lines confirm the helper ran correctly.

Refs: #5780, #6170
@alwx alwx self-assigned this May 18, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Semver Impact of This PR

None (no version bump detected)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


  • WIP: feat(ios): opt-in consumption of sentry-cocoa via Swift Package Manager by alwx in #6182
  • fix(ios): use framework-style import for SentrySwizzle.h by alwx in #6181
  • chore(deps): bump actions/create-github-app-token from 3.1.1 to 3.2.0 by dependabot in #6178
  • chore(deps): bump github/codeql-action from 4.35.4 to 4.35.5 by dependabot in #6176
  • chore(deps): bump getsentry/craft from 2.26.3 to 2.26.5 by dependabot in #6179
  • chore(deps): bump getsentry/craft/.github/workflows/changelog-preview.yml from 2.26.3 to 2.26.5 by dependabot in #6177
  • fix(core): Resolve expo CLI directly instead of using npx in sourcemap upload by antonis in #6155
  • feat(core): Surface textComponentNames option in Metro config by antonis in #6169
  • chore(deps): update Sentry Android Gradle Plugin to v6.7.0 by github-actions in #6153
  • Filter ExceptionsManager.reportException duplicates in app-start init by alwx in #6145
  • chore(deps): update JavaScript SDK to v10.53.1 by github-actions in #6139
  • feat(core): Enable autoInjectSentryLabel by default in Metro config by antonis in #6141
  • feat(core): Respect Mask boundaries when reading sentry-label by antonis in #6142
  • fix(android): Handle boolean values in JSON options converter by antonis in #6130
  • Multi-instance <TimeToInitialDisplay> / <TimeToFullDisplay> coordination; a multi-signal TTID/TTFD system by alwx in #6090
  • chore(deps): update Bundler Plugins to v5.3.0 by github-actions in #6138
  • chore: Merge 8.11.1 back to main by antonis in #6135
  • chore: Update warning regarding iOS crash in sentry-cocoa 9.12.0 by antonis in #6136
  • chore(deps): update CLI to v3.4.2 by github-actions in #6129
  • chore(deps): bump getsentry/craft/.github/workflows/changelog-preview.yml from 2.26.2 to 2.26.3 by dependabot in #6126
  • chore(deps): bump getsentry/craft from 2.26.2 to 2.26.3 by dependabot in #6127
  • chore(deps): bump github/codeql-action from 4.35.3 to 4.35.4 by dependabot in #6128
  • feat(core): Extract text from children of touched components for breadcrumb labels by antonis in #6106
  • chore(deps): bump @babel/plugin-transform-modules-systemjs from 7.25.0 to 7.29.4 by dependabot in #6124

Plus 7 more


🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Copy Markdown
Contributor

Fails
🚫 Pull request is not ready for merge, please add the "ready-to-merge" label to the pull request
🚫 Please consider adding a changelog entry for the next release.

Instructions and example for changelog

Please add an entry to CHANGELOG.md to the "Unreleased" section. Make sure the entry includes this PR's number.

Example:

## Unreleased

### Features

- opt-in consumption of sentry-cocoa via Swift Package Manager ([#6182](https://github.com/getsentry/sentry-react-native/pull/6182))

If none of the above apply, you can opt out of this check by adding #skip-changelog to the PR description or adding a skip-changelog label.

Generated by 🚫 dangerJS against 404d962

Comment on lines +65 to +70
'This requires React Native >= 0.75 and a Podfile that imports ' \
'react_native_pods.rb.'
end
SPM.dependency(s,
url: 'https://github.com/getsentry/sentry-cocoa',
requirement: { kind: 'exactVersion', version: '9.13.0' },
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SPM path pins version 9.13.0 which is missing SentrySessionReplayHybridSDK, causing a linker failure for any app using Session Replay

The SentrySessionReplayHybridSDK symbol—actively referenced in RNSentryReplayBreadcrumbConverter.m—is absent from the sentry-cocoa 9.13.0 xcframework (getsentry/sentry-cocoa#7911). Any project that sets SENTRY_USE_SPM=1 and has Session Replay enabled will fail to link, with no code-level warning surfaced at pod install time. Consider either raising an explicit error when SENTRY_USE_SPM=1 is set (pointing users to wait for the fixed release) or documenting the minimum fixed version in the guard so the pin is updated atomically when the cocoa fix ships.

Verification

Confirmed SentrySessionReplayHybridSDK is called in packages/core/ios/RNSentryReplayBreadcrumbConverter.m (lines 14, 43, 75, 95, 183). The SPM path pins exactVersion: '9.13.0', which the PR body explicitly identifies as having the packaging bug. The CocoaPods path (source build) is unaffected because it compiles from source. No runtime or pod-install-time guard exists in the new code block to catch this for SPM consumers.

Identified by Warden code-review · MTW-NU4

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant