Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to build on react-native-macos 0.74.1 #6421

Open
hsjoberg opened this issue Aug 17, 2024 · 6 comments
Open

Fails to build on react-native-macos 0.74.1 #6421

hsjoberg opened this issue Aug 17, 2024 · 6 comments
Assignees
Labels
Repro provided A reproduction with a snippet of code, snack or repo is provided

Comments

@hsjoberg
Copy link

hsjoberg commented Aug 17, 2024

Description

Hi. When trying to build react-native-reanimated with react-native-macos 0.74.1, the following syntax error is encountered in REASizzledManager.mm#L235 and in other places.

Cannot initialize return object of type 'RCTViewManagerUIBlock' (aka 'void (^)(RCTUIManager *__strong, NSDictionary<NSNumber *,NSView *> *__strong)') with an rvalue of type 'void (^)(RCTUIManager *__strong, NSDictionary<NSNumber *,REAUIView *> *__strong)'

Simply changing REAUIView to NSView everywhere where the compiler complains seems to fix the issue.
But I don't know react-native-reanimated's inner workings well enough to understand if this is a sane approach.
If yes, I can submit a PR.

Also, react-native-gesture-handler has a similar issue as this one. I could file a bug report there too if needed.

Steps to reproduce

Try to build the demo project to see the issue.

Due to an unrelated issue in react-native-macos 0.74.1 microsoft/react-native-macos#2165, you may have to clear out the build phase script [CP-User] [RN]Check rncore in the React-Fabric pod before building.

Snack or a link to a repository

https://github.com/hsjoberg/rnmacos74/tree/reanimated (reanimated branch)

Reanimated version

3.15.0

React Native version

0.74.1

Platforms

macOS

JavaScript runtime

JSC

Workflow

React Native

Architecture

Paper (Old Architecture)

Build type

None

Device

Real device

Device model

No response

Acknowledgements

Yes

@github-actions github-actions bot added the Repro provided A reproduction with a snippet of code, snack or repo is provided label Aug 17, 2024
@hsjoberg
Copy link
Author

hsjoberg commented Sep 2, 2024

It seems like NSView is being expected somewhere instead of REAUIView (which is a typedef of RCTUIView for macOS, not NSView), but I cannot quite figure out where.

@hsjoberg
Copy link
Author

hsjoberg commented Sep 2, 2024

The issue is essentially that RCTViewManagerUIBlock that's being used as arg to reanimated_addUIBlock() expects UIView in react-native and NSView in react-native-macos, but reanimated's REAUIView is typedef'd as RCTUIView on macos. It's therefore incorrectly used here:

[self reanimated_addUIBlock:^(
__unused RCTUIManager *manager, __unused NSDictionary<NSNumber *, REAUIView *> *viewRegistry) {
--isFlushingBlocks;

RCTViewManagerUIBlock:
react-native (iOS): https://github.com/facebook/react-native/blob/ade863a48cd78039dd68e7176e339cdaca3b0f74/packages/react-native/React/Views/RCTViewManager.h#L22

react-native-macos: https://github.com/microsoft/react-native-macos/blob/042cd6c36b23c21d20de628bc9756793e01ce282/packages/react-native/React/Views/RCTViewManager.h#L22 (RCTPlatformView in turn defined as NSView: https://github.com/microsoft/react-native-macos/blob/042cd6c36b23c21d20de628bc9756793e01ce282/packages/react-native/React/Base/RCTUIKit.h#L382).

@hsjoberg
Copy link
Author

hsjoberg commented Sep 2, 2024

Okay, I've quick & dirty fixes for react-native-reanimated and react-native-gesture-handler here:

https://github.com/hsjoberg/react-native-reanimated/tree/rn75fix
https://github.com/hsjoberg/react-native-gesture-handler/tree/rn75fix

Just using #ifdef to output NSView or UIView.

I don't know the proper solution here but I'm happy to make a PR if someone would give some directions.

@tomekzaw
Copy link
Member

tomekzaw commented Sep 16, 2024

@hsjoberg Thanks for the investigation! I think we're okay with #ifdef approach in those cases, feel free to submit a PR.

Alternatively, we can add another typedef REAView which resolves to NSView or UIView to avoid multiple #ifdef.

I'm also curious to learn more about your experience with RNGestureHandler on macOS since this is a pretty new feature that we'd like to get some feedback on (cc @m-bert who's the co-author of the macOS implementation).

@piaskowyk
Copy link
Member

It's likely that this fix will also resolve #6501

@hsjoberg
Copy link
Author

hsjoberg commented Sep 16, 2024

@tomekzaw Sure, I can look into submitting a PR soonish. 🙂

I'm also curious to learn more about your experience with RNGestureHandler on macOS since this is a pretty new feature that we'd like to get some feedback on (cc @m-bert who's the co-author of the macOS implementation).

Sorry, I don't have any direct feedback on regarding RNGestureHandler on macOS. I use @react-navigation/drawer, which pulls it in. I really appreciate react-native-{windows/macos} support for libs though. 💯

@piaskowyk Yes, #6501 is the same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Repro provided A reproduction with a snippet of code, snack or repo is provided
Projects
None yet
Development

No branches or pull requests

4 participants