From 58a4f9d5beb1b4110e1c19df7437092ee01f26f2 Mon Sep 17 00:00:00 2001 From: Alexander Pantiukhov Date: Mon, 18 May 2026 16:50:26 +0200 Subject: [PATCH 1/3] feat(ios): opt-in consumption of sentry-cocoa via Swift Package Manager MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 (``) 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 --- CHANGELOG.md | 1 + packages/core/RNSentry.podspec | 24 +++++++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b3b27c9e49..506ed31ad1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ ### Features +- Opt-in: consume sentry-cocoa via Swift Package Manager. Set `SENTRY_USE_SPM=1` before `pod install` to pull `Sentry` from sentry-cocoa's SPM package as a binary xcframework instead of the CocoaPods source build ([#6182](https://github.com/getsentry/sentry-react-native/pull/6182)) - Add `disableAutoUpload` option to Expo plugin to disable source map and debug symbol uploads ([#6195](https://github.com/getsentry/sentry-react-native/pull/6195)) - Expose `pauseAppHangTracking` and `resumeAppHangTracking` APIs on iOS ([#6192](https://github.com/getsentry/sentry-react-native/pull/6192)) - Better route and dynamic param extraction for Expo Router ([#6197](https://github.com/getsentry/sentry-react-native/pull/6197)) diff --git a/packages/core/RNSentry.podspec b/packages/core/RNSentry.podspec index 45d6338214..f230f92bd9 100644 --- a/packages/core/RNSentry.podspec +++ b/packages/core/RNSentry.podspec @@ -50,7 +50,29 @@ Pod::Spec.new do |s| 'DEFINES_MODULE' => 'YES' } - s.dependency 'Sentry', '9.14.0' + # Opt-in to consuming sentry-cocoa via Swift Package Manager. + # When `SENTRY_USE_SPM=1` is set, RNSentry pulls `Sentry` from the + # sentry-cocoa SPM package as a binary xcframework instead of from + # the Sentry CocoaPods source build. Defaults to CocoaPods consumption + # for backward compatibility with the full RN version range we support. + # + # Requires React Native >= 0.75 because the SPM helper + # (`react-native/scripts/cocoapods/spm.rb`) is loaded transitively from + # the Podfile via `react_native_pods.rb`. + if ENV['SENTRY_USE_SPM'] == '1' + unless defined?(SPM) && SPM.respond_to?(:dependency) + raise 'SENTRY_USE_SPM=1 is set but the SPM helper is not loaded. ' \ + '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' }, + products: ['Sentry'] + ) + else + s.dependency 'Sentry', '9.14.0' + end if defined? install_modules_dependencies # Default React Native dependencies for 0.71 and above (new and legacy architecture) From 15f788d86fab066593d63c4449097ee0105b1d2a Mon Sep 17 00:00:00 2001 From: Alexander Pantiukhov Date: Tue, 26 May 2026 10:47:52 +0200 Subject: [PATCH 2/3] version fix --- packages/core/RNSentry.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/RNSentry.podspec b/packages/core/RNSentry.podspec index f230f92bd9..e5889b9326 100644 --- a/packages/core/RNSentry.podspec +++ b/packages/core/RNSentry.podspec @@ -67,7 +67,7 @@ Pod::Spec.new do |s| end SPM.dependency(s, url: 'https://github.com/getsentry/sentry-cocoa', - requirement: { kind: 'exactVersion', version: '9.13.0' }, + requirement: { kind: 'exactVersion', version: '9.14.0' }, products: ['Sentry'] ) else From a85bee92225acd7743d314e3406816ac3d2d765f Mon Sep 17 00:00:00 2001 From: Alexander Pantiukhov Date: Tue, 26 May 2026 11:00:13 +0200 Subject: [PATCH 3/3] update-cocoa.sh fix --- packages/core/RNSentry.podspec | 6 ++++-- scripts/update-cocoa.sh | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/core/RNSentry.podspec b/packages/core/RNSentry.podspec index e5889b9326..228a947517 100644 --- a/packages/core/RNSentry.podspec +++ b/packages/core/RNSentry.podspec @@ -50,6 +50,8 @@ Pod::Spec.new do |s| 'DEFINES_MODULE' => 'YES' } + sentry_cocoa_version = '9.14.0' + # Opt-in to consuming sentry-cocoa via Swift Package Manager. # When `SENTRY_USE_SPM=1` is set, RNSentry pulls `Sentry` from the # sentry-cocoa SPM package as a binary xcframework instead of from @@ -67,11 +69,11 @@ Pod::Spec.new do |s| end SPM.dependency(s, url: 'https://github.com/getsentry/sentry-cocoa', - requirement: { kind: 'exactVersion', version: '9.14.0' }, + requirement: { kind: 'exactVersion', version: sentry_cocoa_version }, products: ['Sentry'] ) else - s.dependency 'Sentry', '9.14.0' + s.dependency 'Sentry', sentry_cocoa_version end if defined? install_modules_dependencies diff --git a/scripts/update-cocoa.sh b/scripts/update-cocoa.sh index 7d2a5ce0ed..ed6f2e2919 100755 --- a/scripts/update-cocoa.sh +++ b/scripts/update-cocoa.sh @@ -3,7 +3,7 @@ set -euo pipefail file="$(dirname "$0")/../packages/core/RNSentry.podspec" content=$(cat $file) -regex="('Sentry', *)'([0-9\.]+)'" +regex="(sentry_cocoa_version *= *)'([0-9\.]+)'" if ! [[ $content =~ $regex ]]; then echo "Failed to find the plugin version in $file" exit 1