Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions .github/workflows/sample-application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
caller_ref: ${{ github.ref }}

build-ios:
name: Build ${{ matrix.rn-architecture }} ios ${{ matrix.build-type }} ${{ matrix.ios-use-frameworks }}
name: Build ${{ matrix.rn-architecture }} ios ${{ matrix.build-type }} ${{ matrix.ios-use-frameworks }} ${{ matrix.sentry-consumption }}
runs-on: macos-26-xlarge
needs: [diff_check, detect-changes]
if: >-
Expand All @@ -60,6 +60,15 @@ jobs:
rn-architecture: ["new"]
ios-use-frameworks: ["no-frameworks"]
build-type: ["dev", "production"]
sentry-consumption: ["spm"]
# SPM is the default consumption path for sentry-cocoa on RN >= 0.75.
# Keep a single CocoaPods job to catch regressions in the fallback path
# used by older React Native versions.
include:
- rn-architecture: "new"
ios-use-frameworks: "no-frameworks"
build-type: "production"
sentry-consumption: "cocoapods"
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0

Expand Down Expand Up @@ -95,6 +104,7 @@ jobs:
[[ "${{ matrix.build-type }}" == "production" ]] && export ENABLE_PROD=1 || export ENABLE_PROD=0
[[ "${{ matrix.rn-architecture }}" == "new" ]] && export ENABLE_NEW_ARCH=1 || export ENABLE_NEW_ARCH=0
[[ "${{ matrix.ios-use-frameworks }}" == "dynamic-frameworks" ]] && export USE_FRAMEWORKS=dynamic
[[ "${{ matrix.sentry-consumption }}" == "cocoapods" ]] && export SENTRY_USE_SPM=0

./scripts/pod-install.sh

Expand All @@ -112,15 +122,17 @@ jobs:
./scripts/build-ios.sh

- name: Archive iOS App
if: ${{ matrix.rn-architecture == 'new' && matrix.build-type == 'production' && matrix.ios-use-frameworks == 'no-frameworks' }}
# Only upload from the SPM job (the default consumption path) to avoid
# duplicate artifact names when the CocoaPods regression job runs.
if: ${{ matrix.rn-architecture == 'new' && matrix.build-type == 'production' && matrix.ios-use-frameworks == 'no-frameworks' && matrix.sentry-consumption == 'spm' }}
working-directory: ${{ env.REACT_NATIVE_SAMPLE_PATH }}
run: |
zip -r \
${{ github.workspace }}/${{ env.IOS_APP_ARCHIVE_PATH }} \
sentryreactnativesample.app

- name: Upload iOS APP
if: ${{ matrix.rn-architecture == 'new' && matrix.build-type == 'production' && matrix.ios-use-frameworks == 'no-frameworks' }}
if: ${{ matrix.rn-architecture == 'new' && matrix.build-type == 'production' && matrix.ios-use-frameworks == 'no-frameworks' && matrix.sentry-consumption == 'spm' }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: sample-rn-${{ matrix.rn-architecture }}-${{ matrix.build-type }}-${{ matrix.ios-use-frameworks}}-ios
Expand All @@ -131,7 +143,7 @@ jobs:
if: ${{ always() }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: build-sample-${{ matrix.rn-architecture }}-ios-${{ matrix.build-type }}-${{ matrix.ios-use-frameworks}}-logs
name: build-sample-${{ matrix.rn-architecture }}-ios-${{ matrix.build-type }}-${{ matrix.ios-use-frameworks}}-${{ matrix.sentry-consumption }}-logs
path: ${{ env.REACT_NATIVE_SAMPLE_PATH }}/ios/*.log

build-android:
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
### Changes

- Default `mobileReplayIntegration({ networkCaptureBodies })` to `true`, matching the iOS and Android native SDK defaults ([#6372](https://github.com/getsentry/sentry-react-native/pull/6372))
- Consume `sentry-cocoa` via Swift Package Manager by default on React Native >= 0.75 ([#6381](https://github.com/getsentry/sentry-react-native/pull/6381))

**Warning**

**This may be a breaking change for some setups.** On RN 0.75+, `pod install` now pulls Sentry as a pre-built binary xcframework, instead of building Sentry from source as a CocoaPod. If your iOS build breaks after upgrading (e.g. when another pod also depends on the `Sentry` CocoaPod), set `SENTRY_USE_SPM=0` before `pod install` to restore the previous behavior. On older React Native versions the SPM helper is unavailable and RNSentry transparently falls back to the CocoaPods source build. Use `SENTRY_USE_SPM=1` to require SPM.

### Fixes

Expand Down
34 changes: 22 additions & 12 deletions packages/core/RNSentry.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,30 @@ Pod::Spec.new do |s|

sentry_cocoa_version = '9.19.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.
# Consume sentry-cocoa via Swift Package Manager by default.
#
# 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)
# On React Native >= 0.75, RNSentry pulls `Sentry` from the sentry-cocoa SPM
# package (a pre-built binary xcframework). On older RN, the SPM helper
# (`react-native/scripts/cocoapods/spm.rb`) is not available and we
# transparently fall back to the Sentry CocoaPods source build.
#
# Override the choice with the `SENTRY_USE_SPM` environment variable:
# * `SENTRY_USE_SPM=0` โ€” force CocoaPods consumption even on RN >= 0.75.
# * `SENTRY_USE_SPM=1` โ€” force SPM (errors if the helper is unavailable).
spm_helper_available = defined?(SPM) && SPM.respond_to?(:dependency)
env_use_spm = ENV['SENTRY_USE_SPM']
use_spm = case env_use_spm
when '1' then true
when '0' then false
else supports_spm(rn_version) && spm_helper_available
end

if use_spm
unless spm_helper_available
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.'
'This requires React Native >= 0.75 and a Podfile that loads ' \
'`react_native_pods.rb`. Either upgrade React Native, or set ' \
'SENTRY_USE_SPM=0 to fall back to the Sentry CocoaPods build.'
end
SPM.dependency(s,
url: 'https://github.com/getsentry/sentry-cocoa',
Expand Down
9 changes: 9 additions & 0 deletions packages/core/scripts/sentry_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,12 @@ def should_use_folly_flags(rn_version)
def is_new_hermes_runtime(rn_version)
return (rn_version[:major] >= 1 || (rn_version[:major] == 0 && rn_version[:minor] >= 81))
end

# React Native >= 0.75 transitively loads `react-native/scripts/cocoapods/spm.rb`
# via `react_native_pods.rb`, which exposes the `SPM` helper that the RNSentry
# podspec uses to pull `sentry-cocoa` as a Swift Package binary xcframework.
# Below 0.75 the helper is unavailable and we fall back to consuming Sentry as
# a regular CocoaPods source build.
def supports_spm(rn_version)
return (rn_version[:major] >= 1 || (rn_version[:major] == 0 && rn_version[:minor] >= 75))
end
1 change: 1 addition & 0 deletions scripts/clang-format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ cmd="find . -type f \( \
-path \"**android/build/**\" -or \
-path \"**.cxx/**\" -or \
-path \"**build/generated/**\" -or \
-path \"**/DerivedData/**\" -or \
-path \"**/Carthage/Checkouts/*\" -or \
-path \"**/libs/**\" -or \
-path \"**/.yalc/**\" -or \
Expand Down
Loading