Skip to content

Commit 192c333

Browse files
SaadnajmiRSNarajpdrivershwanton
authored
[0.72] Add visionOS support (#2040)
* Remove deprecated uses of UIActivityIndicatorViewStyle (facebook#38208) Summary: Super simple change to replace some deprecated ENUM values with the correct one, now that we're on iOS 13.0+. From `UIActivityIndicator.h`: ``` typedef NS_ENUM(NSInteger, UIActivityIndicatorViewStyle) { UIActivityIndicatorViewStyleMedium API_AVAILABLE(ios(13.0), tvos(13.0)) = 100, UIActivityIndicatorViewStyleLarge API_AVAILABLE(ios(13.0), tvos(13.0)) = 101, UIActivityIndicatorViewStyleWhiteLarge API_DEPRECATED_WITH_REPLACEMENT("UIActivityIndicatorViewStyleLarge", ios(2.0, 13.0), tvos(9.0, 13.0)) = 0, UIActivityIndicatorViewStyleWhite API_DEPRECATED_WITH_REPLACEMENT("UIActivityIndicatorViewStyleMedium", ios(2.0, 13.0), tvos(9.0, 13.0)) = 1, UIActivityIndicatorViewStyleGray API_DEPRECATED_WITH_REPLACEMENT("UIActivityIndicatorViewStyleMedium", ios(2.0, 13.0)) API_UNAVAILABLE(tvos) = 2, }; ``` ## Changelog: [IOS] [CHANGED] - Remove deprecated uses of UIActivityIndicatorViewStyle Pull Request resolved: facebook#38208 Test Plan: CI should pass Reviewed By: cipolleschi Differential Revision: D47254035 Pulled By: rshest fbshipit-source-id: 6d3270899e8d52611d91c777f324c3c6f0c520be * Refactor RCTActivityIndicator * Remove TARGET_OS_UIKITFORMAC macros (facebook#42278) Summary: There seems to be a lot of `TARGET_OS_UIKITFORMAC` macro in React Native that don't need to be there. Let's remove them. First off, what is `TARGET_OS_UIKITFORMAC` targeting? You might think it's [Mac Catalyst](https://developer.apple.com/mac-catalyst/), if you look at the [commit](facebook@3724810) introducing the ifdefs. However.. that doesn't seem right because `TARGET_OS_MACCATALYST` exists, and is used elsewhere in the codebase. In fact, if you look at this handy comment inside `TargetConditionals.h` (the file that defines all these conditionals), `TARGET_OS_UIKITFORMAC` is not even on there! ``` /* * TARGET_OS_* * * These conditionals specify in which Operating System the generated code will * run. Indention is used to show which conditionals are evolutionary subclasses. * * The MAC/WIN32/UNIX conditionals are mutually exclusive. * The IOS/TV/WATCH/VISION conditionals are mutually exclusive. * * TARGET_OS_WIN32 - Generated code will run on WIN32 API * TARGET_OS_WINDOWS - Generated code will run on Windows * TARGET_OS_UNIX - Generated code will run on some Unix (not macOS) * TARGET_OS_LINUX - Generated code will run on Linux * TARGET_OS_MAC - Generated code will run on a variant of macOS * TARGET_OS_OSX - Generated code will run on macOS * TARGET_OS_IPHONE - Generated code will run on a variant of iOS (firmware, devices, simulator) * TARGET_OS_IOS - Generated code will run on iOS * TARGET_OS_MACCATALYST - Generated code will run on macOS * TARGET_OS_TV - Generated code will run on tvOS * TARGET_OS_WATCH - Generated code will run on watchOS * TARGET_OS_VISION - Generated code will run on visionOS * TARGET_OS_BRIDGE - Generated code will run on bridge devices * TARGET_OS_SIMULATOR - Generated code will run on an iOS, tvOS, watchOS, or visionOS simulator * TARGET_OS_DRIVERKIT - Generated code will run on macOS, iOS, tvOS, watchOS, or visionOS * * TARGET_OS_EMBEDDED - DEPRECATED: Use TARGET_OS_IPHONE and/or TARGET_OS_SIMULATOR instead * TARGET_IPHONE_SIMULATOR - DEPRECATED: Same as TARGET_OS_SIMULATOR * TARGET_OS_NANO - DEPRECATED: Same as TARGET_OS_WATCH * * +--------------------------------------------------------------------------------------+ * | TARGET_OS_MAC | * | +-----+ +------------------------------------------------------------+ +-----------+ | * | | | | TARGET_OS_IPHONE | | | | * | | | | +-----------------+ +----+ +-------+ +--------+ +--------+ | | | | * | | | | | IOS | | | | | | | | | | | | | * | | OSX | | | +-------------+ | | TV | | WATCH | | BRIDGE | | VISION | | | DRIVERKIT | | * | | | | | | MACCATALYST | | | | | | | | | | | | | | * | | | | | +-------------+ | | | | | | | | | | | | | * | | | | +-----------------+ +----+ +-------+ +--------+ +--------+ | | | | * | +-----+ +------------------------------------------------------------+ +-----------+ | * +--------------------------------------------------------------------------------------+ */ ``` Going even deeper into `TargetConditionals.h`, you will see `TARGET_OS_UIKITFORMAC` defined... and it's always 1 when `TARGET_OS_MACCATALYST` is 1, making it feel even more redundant. My current conclusion is it's either another variant of Mac Catalyst (the one where they just run unmodified UIKit maybe..), or it's an older macro back from when Catalyst was still experimental. Either way, it's pretty obvious nobody is running or testing this codepath, and it adds bloat, especially to React Native macOS where we have extra ifdef blocks for macOS support (and eventually visionOS support). Let's remove it. Another change I made while we're here: I've seen this lingering TODO to replace setTargetRect:InView: / setMenuVisible:animated: (deprecated as of iOS 13, below our minimum OS requirement) with showMenuFromView (deprecated as of iOS 16, in line with the availability check). Let's just.... do that? [IOS] [REMOVED] - Remove TARGET_OS_UIKITFORMAC macros Pull Request resolved: facebook#42278 Test Plan: RNTester with Mac Catalyst still compiles: ![Screenshot 2024-01-15 at 12 26 03 AM](https://github.com/facebook/react-native/assets/6722175/015bd37d-f536-43c7-9586-96187cdbd013) Reviewed By: cipolleschi Differential Revision: D52780690 Pulled By: sammy-SC fbshipit-source-id: df6a333e8e15f79de0ce6f538ebd73b92698dcb6 * Remove an early return to suppress a deprecated API warning for `UIMenuController` (facebook#42277) Summary: `UIMenuController` is deprecated as of iOS 16. facebook@e08a197 migrated a usage into an `available` check. However, it does not properly fall back to the deprecated API in the "else" block of the availability check, instead it uses an early return. It seems this means Xcode still sees the API as used, and spits out a deprecated warning. Let's just refactor the code so we don't have that anymore. [IOS] [FIXED] - Remove an early return to suppress a deprecated API warning for `UIMenuController` Pull Request resolved: facebook#42277 Test Plan: CI should pass. Reviewed By: cipolleschi Differential Revision: D52785488 Pulled By: sammy-SC fbshipit-source-id: 0b47e8aa8d7c94728e3d68332fbb8f97f8ded34e * DeviceInfo: Simplify RCTExportedDimensions's API Summary: RCTExportedDimensions doesn't need access to the ModuleRegistry, or the bridge. It just uses those two things to get the fontScale. We could make RCTExportedDimensions easier to understand, by making it do fewer things (i.e: computing the fontScale up front, and passing it into RCTExportedDimensions). Let's just do that. Changelog: [Internal] Reviewed By: cipolleschi Differential Revision: D48237715 fbshipit-source-id: b3af648d88276846742d0e1192d33d180ee49dbb * iOS: trigger didUpdateDimensions event when resizing without changing traits (facebook#37649) Summary: - when using the `useWindowDimensions()` hook in a component, it's possible for the hook to report incorrect sizes and not update as frequently as it should - this is most applicable to apps built for iPad and macOS - closes facebook#36118 - either when resizing a React Native app to a different [Size Class](https://developer.apple.com/design/human-interface-guidelines/layout#Device-size-classes) or changing the Appearance, we dispatch an `RCTUserInterfaceStyleDidChangeNotification` notification - these are then handled in the `interfaceFrameDidChange` method of `RCTDeviceInfo` - this results in a `didUpdateDimensions` Device Event, which in turn updates the results of `useWindowDimensions()` - see [RCTDeviceInfo.mm#L217-L232](https://github.com/facebook/react-native/blob/v0.72.0-rc.4/packages/react-native/React/CoreModules/RCTDeviceInfo.mm#L217-L232) - and [Dimensions.js#L119-L124](https://github.com/facebook/react-native/blob/v0.72.0-rc.4/packages/react-native/Libraries/Utilities/Dimensions.js#L119-L124) 🐛 **However** 🐛 - if you are resizing without triggering a `UITraitCollection` change, the Dimensions reported by `useWindowDimensions()` can become stale, until you either:- - hit a certain width that is considered a different Size Class - change the Appearance - background then resume the app - make the app full-screen - added a new `RCTRootViewFrameDidChangeNotification` notification - the thinking here is to avoid additional overhead by re-using the same `RCTUserInterfaceStyleDidChangeNotification` - maybe it's overkill? - the new notifications are sent from an override of `setFrame` on `RCTRootView` - the new notifications call the same `interfaceFrameDidChange` method of `RCTDeviceInfo` - Dimensions are now reported correctly when resizing; even within the same Size Class <!-- Help reviewers and the release process by writing your own changelog entry. Pick one each for the category and type tags: [ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message For more details, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> [IOS] [FIXED] - Dimensions could be reported incorrectly when resizing iPad or macOS apps Pull Request resolved: facebook#37649 Test Plan: **Reproduction: https://github.com/jpdriver/Dimensions** or to recreate it yourself:- - Generate a new project - Change App.tsx ``` import * as React from 'react'; import {View, Text, useWindowDimensions} from 'react-native'; export default function App() { const {width, height} = useWindowDimensions(); return ( <View style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}> <Text>Width: {width}</Text> <Text>Height: {height}</Text> </View> ); } ``` - Open the iOS project in Xcode and enable iPad support - Enable the iPad app to be used in any orientation - Run the app - Enable Stage Manager - Drag one of the corners to resize the app Reviewed By: javache Differential Revision: D46335537 Pulled By: NickGerleman fbshipit-source-id: 1533f511cf3805fdc9629a2ee115cc00e204d82c * Refactor RCTDeviceInfo * Rename `RCTRootViewFrameDidChangeNotification` as it's not trac… (facebook#39835) Summary: …king root view frame changes Looking through where this was introduced (facebook#37649), it seems the notification went from tracking root view size changes to window size changes. However, it was not renamed. I was using it for root view changes in RN-macOS, which.. I guess I'll refactor. Meanwhile, let's update the name? ## Changelog: [IOS] [CHANGED] - Rename `RCTRootViewFrameDidChangeNotification` as it's not tracking root view frame changes Pull Request resolved: facebook#39835 Test Plan: CI should pass Reviewed By: cipolleschi Differential Revision: D50173742 Pulled By: javache fbshipit-source-id: 4651696174c439800984a5e6cf642200bb9c4f3c * Default dimensions `scale` value to 1.0 if window is nil (#1970) * [0.73] Default scale to 1.0 on if window is nil * Unify RCTExportedDimensions between iOS & macOS * Use typedef instead of #define for NSWindow * Fix issues from cherry-picks * Add visionOS support * Extra changes for visionOS on 0.72-stable * Use Xcode 15.2 --------- Co-authored-by: Ramanpreet Nara <ramanpreet@meta.com> Co-authored-by: JP <jpdriver@users.noreply.github.com> Co-authored-by: Shawn Dempsey <96719+shwanton@users.noreply.github.com>
1 parent 64a2ed6 commit 192c333

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+362
-328
lines changed

.ado/variables/vars.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
variables:
2-
VmImageApple: internal-macos12
3-
slice_name: 'Xcode_14.2'
4-
xcode_version: '/Applications/Xcode_14.2.app'
2+
VmImageApple: macos-13
3+
slice_name: 'Xcode_15.2'
4+
xcode_version: '/Applications/Xcode_15.2.app'

packages/react-native/Libraries/AppDelegate/RCTAppDelegate.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,11 @@
5050
* - (id<RCTTurboModule>)getModuleInstanceFromClass:(Class)moduleClass
5151
*/
5252
#if !TARGET_OS_OSX // [macOS]
53-
@interface RCTAppDelegate : UIResponder <UIApplicationDelegate, RCTBridgeDelegate>
53+
@interface RCTAppDelegate : UIResponder <UIApplicationDelegate, UISceneDelegate, RCTBridgeDelegate>
5454
#else // [macOS
5555
@interface RCTAppDelegate : NSResponder <NSApplicationDelegate, RCTBridgeDelegate>
5656
#endif // macOS]
57+
5758
/// The window object, used to render the UViewControllers
5859
@property (nonatomic, strong) RCTPlatformWindow *window; // [macOS]
5960
@property (nonatomic, strong) RCTBridge *bridge;

packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,20 @@ - (void)applicationDidFinishLaunching:(NSNotification *)notification
8585
RCTPlatformView *rootView = [self createRootViewWithBridge:self.bridge moduleName:self.moduleName initProps:initProps]; // [macOS]
8686

8787
#if !TARGET_OS_OSX // [macOS
88+
#if !TARGET_OS_VISION // [visionOS]
8889
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
90+
#else
91+
self.window = [[UIWindow alloc] initWithFrame:CGRectMake(0, 0, 1280, 720)];
92+
#endif // [visionOS]
8993
UIViewController *rootViewController = [self createRootViewController];
9094
rootViewController.view = rootView;
9195
self.window.rootViewController = rootViewController;
96+
self.window.windowScene.delegate = self;
9297
[self.window makeKeyAndVisible];
9398

9499
return YES;
95100
#else // [macOS
96-
NSRect frame = NSMakeRect(0,0,1024,768);
101+
NSRect frame = NSMakeRect(0,0,1280,720);
97102
self.window = [[NSWindow alloc] initWithContentRect:NSZeroRect
98103
styleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskResizable | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable
99104
backing:NSBackingStoreBuffered
@@ -173,6 +178,17 @@ - (BOOL)runtimeSchedulerEnabled
173178
return YES;
174179
}
175180

181+
#pragma mark - UISceneDelegate
182+
#if !TARGET_OS_OSX // [macOS]
183+
- (void)windowScene:(UIWindowScene *)windowScene
184+
didUpdateCoordinateSpace:(id<UICoordinateSpace>)previousCoordinateSpace
185+
interfaceOrientation:(UIInterfaceOrientation)previousInterfaceOrientation
186+
traitCollection:(UITraitCollection *)previousTraitCollection API_AVAILABLE(ios(13.0))
187+
{
188+
[[NSNotificationCenter defaultCenter] postNotificationName:RCTWindowFrameDidChangeNotification object:self];
189+
}
190+
#endif // [macOS]
191+
176192
#pragma mark - RCTCxxBridgeDelegate
177193
- (std::unique_ptr<facebook::react::JSExecutorFactory>)jsExecutorFactoryForBridge:(RCTBridge *)bridge
178194
{

packages/react-native/Libraries/Image/RCTUIImageViewAnimated.m

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,15 +193,10 @@ - (BOOL)paused
193193

194194
- (void)displayDidRefresh:(CADisplayLink *)displayLink
195195
{
196-
#if TARGET_OS_UIKITFORMAC
197-
// TODO: `displayLink.frameInterval` is not available on UIKitForMac
198-
NSTimeInterval durationToNextRefresh = displayLink.duration;
199-
#else
200196
// displaylink.duration -- time interval between frames, assuming maximumFramesPerSecond
201197
// displayLink.preferredFramesPerSecond (>= iOS 10) -- Set to 30 for displayDidRefresh to be called at 30 fps
202198
// durationToNextRefresh -- Time interval to the next time displayDidRefresh is called
203199
NSTimeInterval durationToNextRefresh = displayLink.targetTimestamp - displayLink.timestamp;
204-
#endif
205200
NSUInteger totalFrameCount = self.totalFrameCount;
206201
NSUInteger currentFrameIndex = self.currentFrameIndex;
207202
NSUInteger nextFrameIndex = (currentFrameIndex + 1) % totalFrameCount;

packages/react-native/Libraries/Network/React-RCTNetwork.podspec

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ Pod::Spec.new do |s|
5454
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
5555
"HEADER_SEARCH_PATHS" => header_search_paths.join(' ')
5656
}
57-
s.ios.frameworks = "MobileCoreServices" # [macOS] Restrict to iOS
57+
# [macOS MobileCoreServices Not available on macOS
58+
s.ios.frameworks = "MobileCoreServices"
59+
s.visionos.frameworks = "MobileCoreServices"
60+
# macOS]
5861

5962
s.dependency "RCT-Folly", folly_version
6063
s.dependency "React-Codegen", version

packages/react-native/Libraries/PushNotificationIOS/RCTPushNotificationManager.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@ extern NSString *const RCTRemoteNotificationReceived;
1515
typedef void (^RCTRemoteNotificationCallback)(UIBackgroundFetchResult result);
1616
#endif // [macOS]
1717

18-
#if !TARGET_OS_UIKITFORMAC
1918
+ (void)didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken;
2019
+ (void)didReceiveRemoteNotification:(NSDictionary *)notification;
2120
#if !TARGET_OS_OSX // [macOS]
2221
+ (void)didReceiveRemoteNotification:(NSDictionary *)notification
2322
fetchCompletionHandler:(RCTRemoteNotificationCallback)completionHandler;
23+
#if TARGET_OS_IOS // [visionOS]
2424
+ (void)didReceiveLocalNotification:(UILocalNotification *)notification;
25+
#endif // [visionOS]
2526
#endif // [macOS]
2627
#if TARGET_OS_OSX // [macOS
2728
+ (void)didReceiveUserNotification:(NSUserNotification *)notification;
2829
#endif // macOS]
2930
+ (void)didFailToRegisterForRemoteNotificationsWithError:(NSError *)error;
30-
#endif
3131

3232
@end

packages/react-native/Libraries/PushNotificationIOS/RCTPushNotificationManager.mm

Lines changed: 9 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424

2525
static NSString *const kErrorUnableToRequestPermissions = @"E_UNABLE_TO_REQUEST_PERMISSIONS";
2626

27-
#if !TARGET_OS_UIKITFORMAC
28-
2927
@interface RCTPushNotificationManager () <NativePushNotificationManagerIOSSpec>
3028
@property (nonatomic, strong) NSMutableDictionary *remoteNotificationCallbacks;
3129
@end
@@ -97,16 +95,10 @@ @implementation RCTConvert (UIBackgroundFetchResult)
9795

9896
@end
9997
#endif // [macOS]
100-
#else
101-
@interface RCTPushNotificationManager () <NativePushNotificationManagerIOSSpec>
102-
@end
103-
#endif // TARGET_OS_UIKITFORMAC
10498

10599
@implementation RCTPushNotificationManager
106100

107-
#if !TARGET_OS_UIKITFORMAC
108-
109-
#if !TARGET_OS_OSX // [macOS]
101+
#if TARGET_OS_IOS // [macOS] [visionOS]
110102
/** DEPRECATED. UILocalNotification was deprecated in iOS 10. Please don't add new callsites. */
111103
static NSDictionary *RCTFormatLocalNotification(UILocalNotification *notification)
112104
{
@@ -126,7 +118,8 @@ @implementation RCTPushNotificationManager
126118
formattedLocalNotification[@"remote"] = @NO;
127119
return formattedLocalNotification;
128120
}
129-
#else // [macOS
121+
#endif // [macOS] [visionOS]
122+
#if TARGET_OS_OSX // [macOS
130123
static NSDictionary *RCTFormatUserNotification(NSUserNotification *notification)
131124
{
132125
NSMutableDictionary *formattedUserNotification = [NSMutableDictionary dictionary];
@@ -198,16 +191,13 @@ @implementation RCTPushNotificationManager
198191
return [formatter stringFromDate:date];
199192
}
200193

201-
#endif // TARGET_OS_UIKITFORMAC
202-
203194
RCT_EXPORT_MODULE()
204195

205196
- (dispatch_queue_t)methodQueue
206197
{
207198
return dispatch_get_main_queue();
208199
}
209200

210-
#if !TARGET_OS_UIKITFORMAC
211201
- (void)startObserving
212202
{
213203
[[NSNotificationCenter defaultCenter] addObserver:self
@@ -282,14 +272,15 @@ + (void)didReceiveRemoteNotification:(NSDictionary *)notification
282272
}
283273
#endif // [macOS]
284274

285-
#if !TARGET_OS_OSX // [macOS]
275+
#if TARGET_OS_IOS // [macOS] [visionOS]
286276
+ (void)didReceiveLocalNotification:(UILocalNotification *)notification
287277
{
288278
[[NSNotificationCenter defaultCenter] postNotificationName:kLocalNotificationReceived
289279
object:self
290280
userInfo:RCTFormatLocalNotification(notification)];
291281
}
292-
#else // [macOS
282+
#endif // [macOS] [visionOS]
283+
#if TARGET_OS_OSX // [macOS
293284
+ (void)didReceiveUserNotification:(NSUserNotification *)notification
294285
{
295286
NSString *notificationName = notification.isRemote ? RCTRemoteNotificationReceived : kLocalNotificationReceived;
@@ -568,7 +559,7 @@ - (void)handleRemoteNotificationRegistrationError:(NSNotification *)notification
568559
: (RCTPromiseResolveBlock)resolve reject
569560
: (__unused RCTPromiseRejectBlock)reject)
570561
{
571-
#if !TARGET_OS_OSX // [macOS]
562+
#if TARGET_OS_IOS // [macOS] [visionOS]
572563
NSMutableDictionary<NSString *, id> *initialNotification =
573564
[self.bridge.launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey] mutableCopy];
574565

@@ -583,7 +574,8 @@ - (void)handleRemoteNotificationRegistrationError:(NSNotification *)notification
583574
} else {
584575
resolve((id)kCFNull);
585576
}
586-
#else // [macOS
577+
#endif // [macOS] [visionOS]
578+
#if TARGET_OS_OSX // [macOS
587579
NSUserNotification *initialNotification = self.bridge.launchOptions[NSApplicationLaunchUserNotificationKey];
588580
if (initialNotification) {
589581
resolve(RCTFormatUserNotification(initialNotification));
@@ -638,100 +630,6 @@ - (void)handleRemoteNotificationRegistrationError:(NSNotification *)notification
638630
}];
639631
}
640632

641-
#else // TARGET_OS_UIKITFORMAC
642-
643-
RCT_EXPORT_METHOD(onFinishRemoteNotification : (NSString *)notificationId fetchResult : (NSString *)fetchResult)
644-
{
645-
RCTLogError(@"Not implemented: %@", NSStringFromSelector(_cmd));
646-
}
647-
648-
RCT_EXPORT_METHOD(setApplicationIconBadgeNumber : (double)number)
649-
{
650-
RCTLogError(@"Not implemented: %@", NSStringFromSelector(_cmd));
651-
}
652-
653-
RCT_EXPORT_METHOD(getApplicationIconBadgeNumber : (RCTResponseSenderBlock)callback)
654-
{
655-
RCTLogError(@"Not implemented: %@", NSStringFromSelector(_cmd));
656-
}
657-
658-
RCT_EXPORT_METHOD(requestPermissions
659-
: (JS::NativePushNotificationManagerIOS::SpecRequestPermissionsPermission &)permissions resolve
660-
: (RCTPromiseResolveBlock)resolve reject
661-
: (RCTPromiseRejectBlock)reject)
662-
{
663-
RCTLogError(@"Not implemented: %@", NSStringFromSelector(_cmd));
664-
}
665-
666-
RCT_EXPORT_METHOD(abandonPermissions)
667-
{
668-
RCTLogError(@"Not implemented: %@", NSStringFromSelector(_cmd));
669-
}
670-
671-
RCT_EXPORT_METHOD(checkPermissions : (RCTResponseSenderBlock)callback)
672-
{
673-
RCTLogError(@"Not implemented: %@", NSStringFromSelector(_cmd));
674-
}
675-
676-
RCT_EXPORT_METHOD(presentLocalNotification : (JS::NativePushNotificationManagerIOS::Notification &)notification)
677-
{
678-
RCTLogError(@"Not implemented: %@", NSStringFromSelector(_cmd));
679-
}
680-
681-
RCT_EXPORT_METHOD(scheduleLocalNotification : (JS::NativePushNotificationManagerIOS::Notification &)notification)
682-
{
683-
RCTLogError(@"Not implemented: %@", NSStringFromSelector(_cmd));
684-
}
685-
686-
RCT_EXPORT_METHOD(cancelAllLocalNotifications)
687-
{
688-
RCTLogError(@"Not implemented: %@", NSStringFromSelector(_cmd));
689-
}
690-
691-
RCT_EXPORT_METHOD(cancelLocalNotifications : (NSDictionary<NSString *, id> *)userInfo)
692-
{
693-
RCTLogError(@"Not implemented: %@", NSStringFromSelector(_cmd));
694-
}
695-
696-
RCT_EXPORT_METHOD(getInitialNotification
697-
: (RCTPromiseResolveBlock)resolve reject
698-
: (__unused RCTPromiseRejectBlock)reject)
699-
{
700-
RCTLogError(@"Not implemented: %@", NSStringFromSelector(_cmd));
701-
}
702-
703-
RCT_EXPORT_METHOD(getScheduledLocalNotifications : (RCTResponseSenderBlock)callback)
704-
{
705-
RCTLogError(@"Not implemented: %@", NSStringFromSelector(_cmd));
706-
}
707-
708-
RCT_EXPORT_METHOD(removeAllDeliveredNotifications)
709-
{
710-
RCTLogError(@"Not implemented: %@", NSStringFromSelector(_cmd));
711-
}
712-
713-
RCT_EXPORT_METHOD(removeDeliveredNotifications : (NSArray<NSString *> *)identifiers)
714-
{
715-
RCTLogError(@"Not implemented: %@", NSStringFromSelector(_cmd));
716-
}
717-
718-
RCT_EXPORT_METHOD(getDeliveredNotifications : (RCTResponseSenderBlock)callback)
719-
{
720-
RCTLogError(@"Not implemented: %@", NSStringFromSelector(_cmd));
721-
}
722-
723-
RCT_EXPORT_METHOD(getAuthorizationStatus : (RCTResponseSenderBlock)callback)
724-
{
725-
RCTLogError(@"Not implemented: %@", NSStringFromSelector(_cmd));
726-
}
727-
728-
- (NSArray<NSString *> *)supportedEvents
729-
{
730-
return @[];
731-
}
732-
733-
#endif // TARGET_OS_UIKITFORMAC
734-
735633
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
736634
(const facebook::react::ObjCTurboModule::InitParams &)params
737635
{

packages/react-native/Libraries/Text/Text/RCTTextView.m

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -380,29 +380,21 @@ - (void)disableContextMenu
380380

381381
- (void)handleLongPress:(UILongPressGestureRecognizer *)gesture
382382
{
383-
#if !TARGET_OS_UIKITFORMAC
384-
if (@available(iOS 16.0, *)) {
383+
if (@available(iOS 16.0, macCatalyst 16.0, *)) {
385384
CGPoint location = [gesture locationInView:self];
386385
UIEditMenuConfiguration *config = [UIEditMenuConfiguration configurationWithIdentifier:nil sourcePoint:location];
387386
if (_editMenuInteraction) {
388387
[_editMenuInteraction presentEditMenuWithConfiguration:config];
389388
}
390-
return;
391-
}
392-
// TODO: Adopt showMenuFromRect (necessary for UIKitForMac)
393-
UIMenuController *menuController = [UIMenuController sharedMenuController];
389+
} else {
390+
UIMenuController *menuController = [UIMenuController sharedMenuController];
394391

395-
if (menuController.isMenuVisible) {
396-
return;
397-
}
392+
if (menuController.isMenuVisible) {
393+
return;
394+
}
398395

399-
if (!self.isFirstResponder) {
400-
[self becomeFirstResponder];
396+
[menuController showMenuFromView:self rect:self.bounds];
401397
}
402-
403-
[menuController setTargetRect:self.bounds inView:self];
404-
[menuController setMenuVisible:YES animated:YES];
405-
#endif
406398
}
407399
#else // [macOS
408400

packages/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.m

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,7 @@ - (void)didMoveToWindow
807807

808808
#pragma mark - Custom Input Accessory View
809809

810+
#if TARGET_OS_IOS // [macOS] [visionOS]
810811
- (void)didSetProps:(NSArray<NSString *> *)changedProps
811812
{
812813
if ([changedProps containsObject:@"inputAccessoryViewID"] && self.inputAccessoryViewID) {
@@ -818,7 +819,6 @@ - (void)didSetProps:(NSArray<NSString *> *)changedProps
818819

819820
- (void)setCustomInputAccessoryViewWithNativeID:(NSString *)nativeID
820821
{
821-
#if !TARGET_OS_OSX // [macOS]
822822
__weak RCTBaseTextInputView *weakSelf = self;
823823
[_bridge.uiManager rootViewForReactTag:self.reactTag
824824
withCompletion:^(UIView *rootView) {
@@ -833,12 +833,10 @@ - (void)setCustomInputAccessoryViewWithNativeID:(NSString *)nativeID
833833
}
834834
}
835835
}];
836-
#endif // [macOS]
837836
}
838837

839838
- (void)setDefaultInputAccessoryView
840839
{
841-
#if !TARGET_OS_OSX // [macOS]
842840
UIView<RCTBackedTextInputViewProtocol> *textInputView = self.backedTextInputView;
843841
UIKeyboardType keyboardType = textInputView.keyboardType;
844842

@@ -870,10 +868,8 @@ - (void)setDefaultInputAccessoryView
870868
textInputView.inputAccessoryView = nil;
871869
}
872870
[self reloadInputViewsIfNecessary];
873-
#endif // [macOS]
874871
}
875872

876-
#if !TARGET_OS_OSX // [macOS]
877873
- (void)reloadInputViewsIfNecessary
878874
{
879875
// We have to call `reloadInputViews` for focused text inputs to update an accessory view.
@@ -890,7 +886,7 @@ - (void)handleInputAccessoryDoneButton
890886
[self.backedTextInputView endEditing:YES];
891887
}
892888
}
893-
#endif // [macOS]
889+
#endif // [macOS] [visionOS]
894890

895891
// [macOS
896892

packages/react-native/Libraries/Text/TextInput/Singleline/macOS/RCTUISecureTextField.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
// [macOS]
99

10+
#if TARGET_OS_OSX
1011
#define RCT_SUBCLASS_SECURETEXTFIELD 1
12+
#endif
1113

1214
#include <React/RCTUITextField.h>
15+

0 commit comments

Comments
 (0)