Skip to content

Commit 58a4f9d

Browse files
committed
feat(ios): opt-in consumption of sentry-cocoa via Swift Package Manager
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
1 parent 5ee78d6 commit 58a4f9d

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
### Features
1212

13+
- 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))
1314
- Add `disableAutoUpload` option to Expo plugin to disable source map and debug symbol uploads ([#6195](https://github.com/getsentry/sentry-react-native/pull/6195))
1415
- Expose `pauseAppHangTracking` and `resumeAppHangTracking` APIs on iOS ([#6192](https://github.com/getsentry/sentry-react-native/pull/6192))
1516
- Better route and dynamic param extraction for Expo Router ([#6197](https://github.com/getsentry/sentry-react-native/pull/6197))

‎packages/core/RNSentry.podspec‎

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,29 @@ Pod::Spec.new do |s|
5050
'DEFINES_MODULE' => 'YES'
5151
}
5252

53-
s.dependency 'Sentry', '9.14.0'
53+
# Opt-in to consuming sentry-cocoa via Swift Package Manager.
54+
# When `SENTRY_USE_SPM=1` is set, RNSentry pulls `Sentry` from the
55+
# sentry-cocoa SPM package as a binary xcframework instead of from
56+
# the Sentry CocoaPods source build. Defaults to CocoaPods consumption
57+
# for backward compatibility with the full RN version range we support.
58+
#
59+
# Requires React Native >= 0.75 because the SPM helper
60+
# (`react-native/scripts/cocoapods/spm.rb`) is loaded transitively from
61+
# the Podfile via `react_native_pods.rb`.
62+
if ENV['SENTRY_USE_SPM'] == '1'
63+
unless defined?(SPM) && SPM.respond_to?(:dependency)
64+
raise 'SENTRY_USE_SPM=1 is set but the SPM helper is not loaded. ' \
65+
'This requires React Native >= 0.75 and a Podfile that imports ' \
66+
'react_native_pods.rb.'
67+
end
68+
SPM.dependency(s,
69+
url: 'https://github.com/getsentry/sentry-cocoa',
70+
requirement: { kind: 'exactVersion', version: '9.13.0' },
71+
products: ['Sentry']
72+
)
73+
else
74+
s.dependency 'Sentry', '9.14.0'
75+
end
5476

5577
if defined? install_modules_dependencies
5678
# Default React Native dependencies for 0.71 and above (new and legacy architecture)

0 commit comments

Comments
 (0)