Stub unsupported components for AppleTV (#55198)

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

UISwitch, UIRefreshControl, UIKeyboardNotifications ,and UIPasteBoard are unavailable on AppleTV
https://developer.apple.com/documentation/uikit/uiswitch?language=objc
https://developer.apple.com/documentation/uikit/uirefreshcontrol?language=objc
https://developer.apple.com/documentation/uikit/uiresponder/keyboardwillshownotification?language=objc
https://developer.apple.com/documentation/uikit/uipasteboard?language=objc

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D90712066

fbshipit-source-id: 045836f14e650c655ae669bf5e3bb7fcf693efd3
This commit is contained in:
Devan Buggay authored and meta-codesync[bot] committed 2026-01-16 13:54:04 -08:00
1 parent 1165c07c24
commit 3bc9a5cacb
6 files changed
+82 -3

No files matched your search

@@ -421,6 +421,10 @@ CGSize RCTViewportSize(void)
CGSize RCTSwitchSize(void)
{
// UISwitch is not supported on AppleTV
#if TARGET_OS_TV
return CGSizeMake(0, 0);
#endif
static CGSize rctSwitchSize;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
@@ -7,17 +7,20 @@
#import <React/RCTActionSheetManager.h>
#import <FBReactNativeSpec/FBReactNativeSpec.h>
#import "CoreModulesPlugins.h"
#if !TARGET_OS_TV
#import <React/RCTBridge.h>
#import <React/RCTConvert.h>
#import <React/RCTLog.h>
#import <React/RCTUIManager.h>
#import <React/RCTUtils.h>
#import <FBReactNativeSpec/FBReactNativeSpec.h>
#import <RCTTypeSafety/RCTConvertHelpers.h>
#import "CoreModulesPlugins.h"
using namespace facebook::react;
@interface RCTActionSheetManager () <NativeActionSheetManagerSpec>
@@ -313,6 +316,28 @@ RCT_EXPORT_METHOD(
@end
#else
using namespace facebook::react;
@implementation RCTActionSheetManager
RCT_EXPORT_MODULE()
+ (BOOL)requiresMainQueueSetup
{
return NO;
}
- (std::shared_ptr<TurboModule>)getTurboModule:(const ObjCTurboModule::InitParams &)params
{
return std::make_shared<NativeActionSheetManagerSpecJSI>(params);
}
@end
#endif
Class RCTActionSheetManagerCls(void)
{
return RCTActionSheetManager.class;
@@ -28,14 +28,20 @@ RCT_EXPORT_MODULE()
RCT_EXPORT_METHOD(setString : (NSString *)content)
{
#if !TARGET_OS_TV
UIPasteboard *clipboard = [UIPasteboard generalPasteboard];
clipboard.string = (content ?: @"");
#endif
}
RCT_EXPORT_METHOD(getString : (RCTPromiseResolveBlock)resolve reject : (__unused RCTPromiseRejectBlock)reject)
{
#if !TARGET_OS_TV
UIPasteboard *clipboard = [UIPasteboard generalPasteboard];
resolve((clipboard.string ?: @""));
#else
resolve(@"");
#endif
}
- (std::shared_ptr<TurboModule>)getTurboModule:(const ObjCTurboModule::InitParams &)params
@@ -24,6 +24,7 @@ RCT_EXPORT_MODULE()
- (void)startObserving
{
#if !TARGET_OS_TV
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
#define ADD_KEYBOARD_HANDLER(NAME, SELECTOR) [nc addObserver:self selector:@selector(SELECTOR:) name:NAME object:nil]
@@ -36,6 +37,7 @@ RCT_EXPORT_MODULE()
ADD_KEYBOARD_HANDLER(UIKeyboardDidChangeFrameNotification, keyboardDidChangeFrame);
#undef ADD_KEYBOARD_HANDLER
#endif
}
- (NSArray<NSString *> *)supportedEvents
@@ -82,6 +84,7 @@ IMPLEMENT_KEYBOARD_HANDLER(keyboardDidChangeFrame)
@end
#if !TARGET_OS_TV
NS_INLINE NSDictionary *RCTRectDictionaryValue(CGRect rect)
{
return @{
@@ -131,6 +134,14 @@ static NSDictionary *RCTParseKeyboardNotification(NSNotification *notification)
};
}
#else
static NSDictionary *RCTParseKeyboardNotification(NSNotification *notification)
{
return @{};
}
#endif
Class RCTKeyboardObserverCls(void)
{
return RCTKeyboardObserver.class;
@@ -23,6 +23,22 @@ using namespace facebook::react;
@interface RCTPullToRefreshViewComponentView () <RCTPullToRefreshViewViewProtocol, RCTRefreshableProtocol>
@end
#if TARGET_OS_TV
@implementation RCTPullToRefreshViewComponentView
- (void)setNativeRefreshing:(BOOL)refreshing
{
}
- (void)setRefreshing:(BOOL)refreshing
{
}
@end
#else
@implementation RCTPullToRefreshViewComponentView {
UIRefreshControl *_refreshControl;
RCTScrollViewComponentView *__weak _scrollViewComponentView;
@@ -259,6 +275,8 @@ using namespace facebook::react;
@end
#endif
Class<RCTComponentViewProtocol> RCTPullToRefreshViewCls(void)
{
return RCTPullToRefreshViewComponentView.class;
@@ -21,6 +21,19 @@ using namespace facebook::react;
@interface RCTSwitchComponentView () <RCTSwitchViewProtocol>
@end
#if TARGET_OS_TV
@implementation RCTSwitchComponentView {
}
- (void)setValue:(BOOL)value
{
}
@end
#else
@implementation RCTSwitchComponentView {
UISwitch *_switchView;
BOOL _isInitialValueSet;
@@ -127,6 +140,8 @@ using namespace facebook::react;
@end
#endif
Class<RCTComponentViewProtocol> RCTSwitchCls(void)
{
return RCTSwitchComponentView.class;