Skip to content

Commit 27401dc

Browse files
fkgozalifacebook-github-bot
authored andcommitted
Fix -Wnullable-to-nonnull-conversion for Xcode 26.4
Summary: The fix adds null-coalescing fallbacks (`?: ""`) for UTF8String calls that return `const char * _Nullable` but are passed to `std::string` constructors or C++ functions expecting `const char * _Nonnull`. Changelog: [Internal] Differential Revision: D101668743
1 parent 3fb1fea commit 27401dc

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

packages/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTTextLayoutManager.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ - (LinesMeasurements)getLinesForAttributedString:(facebook::react::AttributedStr
209209

210210
CGFloat baseline = [layoutManager locationForGlyphAtIndex:range.location].y;
211211
auto line = LineMeasurement{
212-
std::string([renderedString UTF8String]),
212+
std::string([renderedString UTF8String] ?: ""),
213213
rect,
214214
overallRect.size.height - baseline,
215215
font.capHeight,

packages/rn-tester/NativeComponentExample/ios/RNTMyNativeViewCommon.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ @implementation UIView (ColorOverlays)
1111

1212
- (void)setBackgroundColorWithColorString:(NSString *)colorString
1313
{
14-
UIColor *color = [UIView UIColorFromHexString:std::string([colorString UTF8String])];
14+
UIColor *color = [UIView UIColorFromHexString:std::string([colorString UTF8String] ?: "")];
1515
self.backgroundColor = color;
1616
}
1717

@@ -23,7 +23,7 @@ - (void)addColorOverlays:(const NSArray *)overlayColors
2323
id colorString = [overlayColors objectAtIndex:i];
2424
CGRect rect = CGRectMake(viewBounds.origin.x + width * i, viewBounds.origin.y, width, viewBounds.size.height);
2525
UIView *overlayView = [[UIView alloc] initWithFrame:rect];
26-
UIColor *color = [UIView UIColorFromHexString:std::string([colorString UTF8String])];
26+
UIColor *color = [UIView UIColorFromHexString:std::string([colorString UTF8String] ?: "")];
2727
overlayView.backgroundColor = color;
2828
[self addSubview:overlayView];
2929
}

0 commit comments

Comments
 (0)