From f8beb942333a7406af035f462d4e2bbaf5d6e7cb Mon Sep 17 00:00:00 2001 From: Kevin Gozali Date: Wed, 22 Apr 2026 11:37:59 -0700 Subject: [PATCH] Fix RCTTextLayoutManager nullable conversion (#56547) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/56547 The original fix in `RCTTextLayoutManager.mm` used the pattern `[obj UTF8String] != nullptr ? [obj UTF8String] : ""`, but Clang's null analysis still types the first operand as `_Nullable`, so `-Wnullable-to-nonnull-conversion` is still triggered as a hard error under Xcode 26.4. Switch to the local-variable pattern that was already used correctly for `RNTMyNativeViewCommon.mm`: ``` const char *renderedUTF8 = [renderedString UTF8String]; ... std::string(renderedUTF8 != nullptr ? renderedUTF8 : "") ... ``` Changelog: [Internal] Reviewed By: javache Differential Revision: D101920741 --- .../react/renderer/textlayoutmanager/RCTTextLayoutManager.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTTextLayoutManager.mm b/packages/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTTextLayoutManager.mm index 32b0798926d..ac553045a9c 100644 --- a/packages/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTTextLayoutManager.mm +++ b/packages/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTTextLayoutManager.mm @@ -208,9 +208,9 @@ - (LinesMeasurements)getLinesForAttributedString:(facebook::react::AttributedStr .width = usedRect.size.width, .height = usedRect.size.height}}; CGFloat baseline = [layoutManager locationForGlyphAtIndex:range.location].y; + const char *renderedUTF8 = [renderedString UTF8String]; auto line = LineMeasurement{ - std::string( - [renderedString UTF8String] != nullptr ? [renderedString UTF8String] : ""), + std::string(renderedUTF8 != nullptr ? renderedUTF8 : ""), rect, overallRect.size.height - baseline, font.capHeight,