[RUMS-18012] [RN 0.87] fix: 'RCTParagraphComponentView.h' file not found - #1365
[RUMS-18012] [RN 0.87] fix: 'RCTParagraphComponentView.h' file not found#1365marco-saia-datadog wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes build failures on iOS for React Native 0.87 projects using @datadog/mobile-react-native-session-replay by removing compile-time dependencies on non-exposed React-RCTFabric headers (RN 0.87 prebuilt core CocoaPods facades). Also adjusts Android RUM initialization code to avoid kotlin.time usage when converting initialResourceThreshold from seconds to milliseconds.
Changes:
- iOS: Resolve
RCTParagraphComponentViewand its props/text access dynamically (runtime lookup + KVC/IMP) to avoid importingReact-RCTFabricinternal headers under RN 0.87. - iOS: Guard
RCTConversions.himport behindRCT_VERSION_MINOR <= 73to match the only branch that needs it. - Android: Replace
kotlin.timeseconds-to-millis conversion with a manual conversion and add a local constant.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/react-native-session-replay/ios/Sources/RCTFabricWrapper.mm | Removes hard header dependency on RCTParagraphComponentView by dynamically resolving the class and props/text access for RN 0.87 CocoaPods facades. |
| packages/core/android/src/main/kotlin/com/datadog/reactnative/DdSdkNativeInitialization.kt | Reworks initialResourceThreshold seconds→milliseconds conversion without kotlin.time, adds a milliseconds-per-second constant. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
e44f3e8 to
6127279
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
Suppressed comments (1)
packages/react-native-session-replay/ios/Sources/RCTFabricWrapper.mm:33
NSClassFromString(@"RCTParagraphComponentView")is executed on every call; this method is likely invoked frequently during snapshotting, so repeated class lookups add avoidable overhead. Cache the resolved class withdispatch_onceand reuse it.
Class paragraphComponentViewClass = NSClassFromString(@"RCTParagraphComponentView");
if (paragraphComponentViewClass == nil || ![view isKindOfClass:paragraphComponentViewClass]) {
return nil;
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
Suppressed comments (1)
packages/react-native-session-replay/ios/Sources/RCTFabricWrapper.mm:38
- This change introduces runtime-only behavior (resolving
RCTParagraphComponentView/propsdynamically and readingattributedTextvia KVC) but there are no iOS unit tests exercisingRCTFabricWrapper’s new-arch extraction path. Without a test, regressions (e.g., selector name changes, unexpected return types, missing KVC compliance) would only be caught at runtime.
Consider adding an XCTest that defines a lightweight fake RCTParagraphComponentView class at runtime (via objc_allocateClassPair) that implements -props and attributedText, then asserts tryToExtractTextPropertiesFromView: returns the expected wrapper for that view and nil for non-matching views.
Class paragraphComponentViewClass = NSClassFromString(@"RCTParagraphComponentView");
if (paragraphComponentViewClass == nil || ![view isKindOfClass:paragraphComponentViewClass]) {
return nil;
}
// `-props` is declared on RCTComponentViewProtocol (not on RCTParagraphComponentView
// itself) and returns a C++ shared_ptr, so it can't be reached through KVC — look it up
// and call it directly via its IMP instead of importing the protocol's header.
SEL propsSelector = NSSelectorFromString(@"props");
|
Closed in favour of #1368 |
What does this PR do?
Building the iOS app on a React Native 0.87 project with
@datadog/mobile-react-native-session-replayfails with:Root cause
RN 0.87 introduces a new prebuilt React Native core CocoaPods facade mechanism (
node_modules/react-native/scripts/cocoapods/rncore_facades.rb). It replaces several pods real podspecs, includingReact-RCTFabric, with an empty placeholder pod whose headers live inside the prebuiltReact.xcframework. No public headers are exposed anymore except those from a narrow allowlist (FACADE_REEXPOSED_HEADERS), which today only containsRCTFabricComponentsPlugins.h.RCTFabricWrapper.mminpackages/react-native-session-replay/ios/Sources/quote-imports some headers fromReact-RCTFabric, that are not on the facade allowlist:RCTParagraphComponentView.hRCTConversions.h(only needed for theRCT_VERSION_MINOR <= 73)Fix
Since we can't change RN's facade allowlist, the fix must be applied on our side: stop relying on CocoaPods quoted-header resolution of
React-RCTFabric-internaltypes:Resolve
RCTParagraphComponentViewdynamically viaNSClassFromStringinstead of the compile-time class symbol (removes the header import entirely).Read
attributedTextvia KVC instead of a direct property access.Call
-propsvia a raw IMP looked up withmethodForSelector:Guard
#import "RCTConversions.h"behind#if RCT_VERSION_MINOR <= 73matching the only branch that actually needs it.Review checklist (to be filled by reviewers)