Skip to content

Commit dabcb3c

Browse files
alwxclaude
andcommitted
fix(ios): Gate Swift link stub inclusion on RN >= 0.75
Adding a Swift file to RNSentry.podspec's source_files (to force Xcode to link Swift runtime compat libs when consuming Sentry.xcframework) made CocoaPods treat RNSentry as a 'Swift pod'. On RN < 0.75, React-hermes doesn't define modular headers, so pod install fails: The Swift pod `RNSentry` depends upon `React-hermes`, which does not define modules. The Swift compat lib linkage is only needed when linking Sentry.xcframework's static Swift symbols into a dynamic framework (use_frameworks! :dynamic), which is a RN 0.86+ scenario anyway. Gate the .swift file on RN >= 0.75 to preserve pod install on the older matrix cells. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent f78fc85 commit dabcb3c

1 file changed

Lines changed: 18 additions & 5 deletions

File tree

packages/core/RNSentry.podspec

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,24 @@ Pod::Spec.new do |s|
4545
# is pulled in here; on Android it is compiled by the dedicated CMake target
4646
# in `android/CMakeLists.txt`. The files are guarded with
4747
# `RCT_NEW_ARCH_ENABLED` so they compile to empty TUs on Old Arch.
48-
# `.swift` is here for `RNSentrySwiftLinkStub.swift`, which forces Xcode
49-
# to link the Swift runtime compatibility libs required by our vendored
50-
# Sentry.xcframework static Swift library.
51-
s.source_files = 'ios/**/*.{h,m,mm,swift}', 'cpp/**/*.{h,cpp}'
52-
s.swift_versions = ['5.5']
48+
#
49+
# We include `.swift` (for `RNSentrySwiftLinkStub.swift`) only on RN >=
50+
# 0.75. Adding a Swift file makes CocoaPods treat RNSentry as a Swift
51+
# pod, which then requires modular headers from its ObjC dependencies
52+
# (React-Core, React-hermes) — RN < 0.75 doesn't emit those, so
53+
# `pod install` fails with:
54+
# "The Swift pod `RNSentry` depends upon `React-hermes`, which does
55+
# not define modules."
56+
# The stub is only needed when linking Sentry.xcframework's Swift
57+
# symbols into a dynamic framework anyway (RN 0.86+ `use_frameworks!
58+
# :dynamic`), so gating on RN 0.75 is safe.
59+
supports_swift_stub = rn_version[:major] >= 1 || (rn_version[:major] == 0 && rn_version[:minor] >= 75)
60+
if supports_swift_stub
61+
s.source_files = 'ios/**/*.{h,m,mm,swift}', 'cpp/**/*.{h,cpp}'
62+
s.swift_versions = ['5.5']
63+
else
64+
s.source_files = 'ios/**/*.{h,m,mm}', 'cpp/**/*.{h,cpp}'
65+
end
5366
s.exclude_files = 'ios/Vendor/**/*'
5467
s.public_header_files = 'ios/RNSentry.h', 'ios/RNSentrySDK.h', 'ios/RNSentryStart.h', 'ios/RNSentryVersion.h', 'ios/RNSentryBreadcrumb.h', 'ios/RNSentryReplay.h', 'ios/RNSentryReplayBreadcrumbConverter.h', 'ios/Replay/RNSentryReplayMask.h', 'ios/Replay/RNSentryReplayUnmask.h', 'ios/RNSentryTimeToDisplay.h'
5568

0 commit comments

Comments
 (0)