Fix -Wnullable-to-nonnull-conversion for Xcode 26.4 (#56518)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/56518

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]

Reviewed By: christophpurrer

Differential Revision: D101668743

fbshipit-source-id: 80920f25317b0c258387f4b2701b35afe20e3896
This commit is contained in:
Kevin Gozali authored and meta-codesync[bot] committed 2026-04-20 18:04:20 -07:00
1 parent c53336909f
commit b2aa6947d1
2 files changed
+6 -3

No files matched your search

@@ -11,7 +11,8 @@
- (void)setBackgroundColorWithColorString:(NSString *)colorString
{
UIColor *color = [UIView UIColorFromHexString:std::string([colorString UTF8String])];
const char *colorUTF8 = [colorString UTF8String];
UIColor *color = [UIView UIColorFromHexString:std::string(colorUTF8 != nullptr ? colorUTF8 : "")];
self.backgroundColor = color;
}
@@ -23,7 +24,8 @@
id colorString = [overlayColors objectAtIndex:i];
CGRect rect = CGRectMake(viewBounds.origin.x + width * i, viewBounds.origin.y, width, viewBounds.size.height);
UIView *overlayView = [[UIView alloc] initWithFrame:rect];
UIColor *color = [UIView UIColorFromHexString:std::string([colorString UTF8String])];
const char *colorUTF8 = [colorString UTF8String];
UIColor *color = [UIView UIColorFromHexString:std::string(colorUTF8 != nullptr ? colorUTF8 : "")];
overlayView.backgroundColor = color;
[self addSubview:overlayView];
}