Closed Saadnajmi closed 2 weeks ago
In React Native macOS, we have two "shim" classes to help make the iOS codebase of React Native compatible with macOS
RCTPlatformView
NSView
UIView
RCTUIView
Additionally, in React Native's old architecture, there is this line that we forked as follows in 0.73 and earlier versions:
React Native:
typedef void (^RCTViewManagerUIBlock)(RCTUIManager uiManager, NSDictionary<NSNumber , UIView > viewRegistry);
React Native macOS:
typedef void (^RCTViewManagerUIBlock)(RCTUIManager uiManager, NSDictionary<NSNumber , **RCTUIView**> viewRegistry); // [macOS]`
In React Native macOS 0.74+, I changed the definition as follows, thinking the widening of scope to a superclass would be a non breaking change:
typedef void (^RCTViewManagerUIBlock)(RCTUIManager uiManager, NSDictionary<NSNumber , **RCTPlatformView**> viewRegistry); // [macOS]`
Turns out I was wrong, and this broke libraries like Reanimated and React Native Gesture Handler. The fix is simple, add a __kindof in front of the type!
__kindof
typedef void (^RCTViewManagerUIBlock)(RCTUIManager uiManager, NSDictionary<NSNumber , **__kindof RCTPlatformView**> viewRegistry); // [macOS]`
Tested this in my branch where I'm adding macOS support to react-native-webgpu (https://github.com/wcandillon/react-native-webgpu/pull/123), and reanimated + gesture gesture handler compile successfully.
Summary:
In React Native macOS, we have two "shim" classes to help make the iOS codebase of React Native compatible with macOS
RCTPlatformView
:a typedef ofNSView
on macOS, andUIView
on iOS / visionOS)RCTUIView
: A subclass ofNSView
with extra methods and properties to be closer to the iOSUIView
Additionally, in React Native's old architecture, there is this line that we forked as follows in 0.73 and earlier versions:
React Native:
React Native macOS:
In React Native macOS 0.74+, I changed the definition as follows, thinking the widening of scope to a superclass would be a non breaking change:
Turns out I was wrong, and this broke libraries like Reanimated and React Native Gesture Handler. The fix is simple, add a
__kindof
in front of the type!Test Plan:
Tested this in my branch where I'm adding macOS support to react-native-webgpu (https://github.com/wcandillon/react-native-webgpu/pull/123), and reanimated + gesture gesture handler compile successfully.