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..228a947517 100644 --- a/packages/core/RNSentry.podspec +++ b/packages/core/RNSentry.podspec @@ -50,7 +50,31 @@ Pod::Spec.new do |s| 'DEFINES_MODULE' => 'YES' } - s.dependency 'Sentry', '9.14.0' + 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 + # 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: sentry_cocoa_version }, + products: ['Sentry'] + ) + else + s.dependency 'Sentry', sentry_cocoa_version + end if defined? install_modules_dependencies # Default React Native dependencies for 0.71 and above (new and legacy architecture) 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