From 404d9626fe913da5684c2be45b9a506a71e69df7 Mon Sep 17 00:00:00 2001 From: Alexander Pantiukhov Date: Mon, 18 May 2026 16:50:26 +0200 Subject: [PATCH] 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 d712d13913..67d3181f2f 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. Requires React Native >= 0.75. Default behavior (CocoaPods) is unchanged. ([#TBD](https://github.com/getsentry/sentry-react-native/pull/TBD)) - Multi-instance `` / `` coordination ([#6090](https://github.com/getsentry/sentry-react-native/pull/6090)) - New `ready` prop. When a screen has multiple async data sources, mount one `` per source — TTID/TTFD is recorded only when every instance reports `ready === true`. - The existing `record` prop is unchanged BUT it is now deprecated in favor of `ready`. diff --git a/packages/core/RNSentry.podspec b/packages/core/RNSentry.podspec index 823904a6fe..3f6f3a1506 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.13.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.13.0' + end if defined? install_modules_dependencies # Default React Native dependencies for 0.71 and above (new and legacy architecture)