software-mansion / react-native-reanimated

React Native's Animated library reimplemented
https://docs.swmansion.com/react-native-reanimated/
MIT License
9.04k stars 1.3k forks source link

iOS: Version 2.17.0 fails to build on React Native 0.72.0+ #4522

Closed jbrowning closed 1 year ago

jbrowning commented 1 year ago

Description

Version 2.17.0 of this library encounters C++ dialect-related build errors on React Native 0.72.0-rc.5:

❌  /Users/jeff/Projects/groove/deps/react-native-app/RNReanimated2/ios/Pods/Headers/Public/React-cxxreact/cxxreact/NativeModule.h:28:26: no template named 'optional' in namespace 'std'; did you mean 'folly::Optional'?

using MethodCallResult = std::optional<folly::dynamic>;
                                  ^
❌  /Users/jeff/Projects/groove/deps/react-native-app/RNReanimated2/ios/Pods/Headers/Public/React-cxxreact/cxxreact/ModuleRegistry.h:50:3: no template named 'optional' in namespace 'std'; did you mean 'folly::Optional'?

  std::optional<ModuleConfig> getConfig(const std::string &name);
      ^
❌  /Users/jeff/Projects/groove/deps/react-native-app/RNReanimated2/ios/Pods/Headers/Public/React-jsiexecutor/jsireact/JSINativeModules.h:30:3: no template named 'optional' in namespace 'std'; did you mean 'folly::Optional'?

  std::optional<jsi::Function> m_genNativeModuleJS;
      ^
❌  /Users/jeff/Projects/groove/deps/react-native-app/RNReanimated2/ios/Pods/Headers/Public/React-jsiexecutor/jsireact/JSINativeModules.h:34:3: no template named 'optional' in namespace 'std'; did you mean 'folly::Optional'?

  std::optional<jsi::Object> createModule(
      ^
❌  /Users/jeff/Projects/groove/deps/react-native-app/RNReanimated2/ios/Pods/Headers/Public/React-jsiexecutor/jsireact/JSIExecutor.h:131:3: no template named 'optional' in namespace 'std'; did you mean 'folly::Optional'?

  std::optional<jsi::Function> callFunctionReturnFlushedQueue_;
      ^
❌  /Users/jeff/Projects/groove/deps/react-native-app/RNReanimated2/ios/Pods/Headers/Public/React-jsiexecutor/jsireact/JSIExecutor.h:132:3: no template named 'optional' in namespace 'std'; did you mean 'folly::Optional'?

  std::optional<jsi::Function> invokeCallbackAndReturnFlushedQueue_;
      ^
❌  /Users/jeff/Projects/groove/deps/react-native-app/RNReanimated2/ios/Pods/Headers/Public/React-jsiexecutor/jsireact/JSIExecutor.h:133:3: no template named 'optional' in namespace 'std'; did you mean 'folly::Optional'?

  std::optional<jsi::Function> flushedQueue_;
      ^

Changing the C++ dialect setting to match the new React Native c++17 default seems to resolve this issue. We, like others, are stuck on Reanimated 2.x due to react-native-vision-camera.

Steps to reproduce

  1. Create a bare React Native project on 0.72.0-rc.5
  2. Ensure that it build successfully on iOS
  3. Install Reanimated 2.17.0
  4. Attempt to build on iOS again

Snack or a link to a repository

https://github.com/jbrowning/RN072Reanimated2

Reanimated version

2.17.0

React Native version

0.72.0-rc.5

Platforms

iOS

JavaScript runtime

None

Workflow

React Native (without Expo)

Architecture

Paper (Old Architecture)

Build type

None

Device

None

Device model

No response

Acknowledgements

Yes

tomekzaw commented 1 year ago

Hey @jbrowning, thanks for reporting this issue. Currently, Reanimated 2 doesn't support 0.72.0-rc.5, but Reanimated 3 does with this patch #4523 so please upgrade if possible 🙏

AlexanderEggers commented 1 year ago

@tomekzaw Do you have any plans to add RN 0.72 support for Reanimated 2? My project won't be able to upgrade to Reanimated 3 any time soon but we would like to keep using the latest RN version.

sylvainbaronnet commented 1 year ago

same, is there a patch to add support for v2 ?

tomekzaw commented 1 year ago

My project won't be able to upgrade to Reanimated 3 any time soon

@AlexanderEggers Can I ask you what's the reason why your project is not able to upgrade to Reanimated 3?

sylvainbaronnet commented 1 year ago

Hi @tomekzaw , If I remember well, I think in my case it was an issue with https://github.com/dohooo/react-native-reanimated-carousel maybe with react-native-gesture-handler too

AlexanderEggers commented 1 year ago

@tomekzaw This is our current blocker: https://github.com/software-mansion/react-native-reanimated/issues/4613 Everything else seems to run fine for us.

tomekzaw commented 1 year ago

@AlexanderEggers Thanks for quick response. I think it's way easier for us to resolve this issue than to backport support for 0.72 to v2 😄 Will take a look at it again soon.

tomekzaw commented 1 year ago

@sylvainbaronnet Can you please post a link to the specific issue?

sylvainbaronnet commented 1 year ago

I will try again today to tell you exactly what's the issue

sylvainbaronnet commented 1 year ago

@tomekzaw I successfully upgraded to v3 (on RN 0.71) so all good for me (I must have already upgraded other packages that had issues with v3 in the past or it's the latest v3 that fixed it)

camilossantos2809 commented 1 year ago

Are there plans to add support for react-native v0.72 in reanimated v2? Currently I cannot update reanimated to v3 in my projects as vision-camera is not yet compatible with that version.

Ar-Shak commented 1 year ago

Similar to @camilossantos2809 I cannot update reanimated to v3 in my project due to react-native-vision-camera and its plugin vision-camera-code-scanner.

martan-fitsense commented 1 year ago

Similar to @arshak-kahnputers I'm blocked by reanimated v3 and my project cannot be built successfully cuz I'm using react-native-vision-camera too.

sebastien-abbal commented 1 year ago

Same for me ... HELP !

AlexanderEggers commented 1 year ago

@tomekzaw We found another blocker for updating to v3.. it seems like that the useAnimatedProps hook is broken in v3. I will try to create an issue for that in the next days including an example to reproduce that.

metrix-hu commented 1 year ago

@tomekzaw We are also in the VisionCamera situation.

tomekzaw commented 1 year ago

@metrix-hu Thanks for the update, that's exactly what I'm working on currently so fingers crossed!

metrix-hu commented 1 year ago

@tomekzaw I am crossing them hard, because I am really stuck now. react-native complained about the update, so I did. For that I modified at least 20 files in my project and I do not really want to revert them 😄 I am working on Android right now though. Thank you very much for looking at it!

metrix-hu commented 1 year ago

I also tried to update everything to V3 but vision-camera is really in early stages especially on Android. I tried modifying its files here and there but couldnt make it to build.

tectiv3 commented 1 year ago

Simply changing the dialect fixes the issue

image

metrix-hu commented 1 year ago

@tectiv3 Can we set it somehow for android too?

paulschoen commented 1 year ago

Simply changing the dialect fixes the issue

image

I can confirm this does fix it. Only issue is when you have a remote CI server that does a pod install it can't change the pod file dialect. Can this be a minor release just to change this?

In my project I'm also using is vision-camera

paulschoen commented 1 year ago

Simply changing the dialect fixes the issue image

I can confirm this does fix it. Only issue is when you have a remote CI server that does a pod install it can't change the pod file dialect. Can this be a minor release just to change this?

In my project I'm also using is vision-camera

The fix for iOS should be on version v2.17.0

# RNReanimated.podspec

  s.pod_target_xcconfig = {
    "USE_HEADERMAP" => "YES",
    "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_TARGET_SRCROOT)\" \"$(PODS_ROOT)/#{folly_prefix}Folly\" \"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/Headers/Private/React-Core\" ",
    "FRAMEWORK_SEARCH_PATHS" => "\"${PODS_CONFIGURATION_BUILD_DIR}/React-hermes\"",
    "CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
  }
felginep commented 1 year ago

Simply changing the dialect fixes the issue image

I can confirm this does fix it. Only issue is when you have a remote CI server that does a pod install it can't change the pod file dialect. Can this be a minor release just to change this?

In my project I'm also using is vision-camera

You can update your Podfile to override this build setting during pod install:

installer.generated_projects.each do |project|
  project.targets.each do |target|
    target.build_configurations.each do |config|
      if target.name === "RNReanimated"
        config.build_settings['CLANG_CXX_LANGUAGE_STANDARD'] = 'c++17'
      end
      ...
    end
  end
end

On my side, this does not fix the problem. The project now builds on iOS but triggers an error at runtime:

 ERROR  [Reanimated] Couldn't determine the version of the native part of Reanimated. Did you forget to re-build the app after upgrading react-native-reanimated? If you use Expo Go, you must use the exact version which is bundled into Expo SDK.
 ERROR  TypeError: Cannot read property 'installCoreFunctions' of undefined, js engine: hermes
elliottkember commented 1 year ago

I'm seeing the same as @felginep on 0.72.1 and 2.17.0. Looks like that was updated on the main branch in this commit but it was in with all the new-architecture changes so I had trouble finding any clues there

wmonecke commented 1 year ago

This is also a blocker for us. Any news or workarounds?

LeoAnt02 commented 1 year ago

I'm facing the same issue, would love to have the support for 0.72 with reanimated v2 @elliottkember

agusvazquez commented 1 year ago

I cannot update to version 3.0 because of this issue :(

https://github.com/react-navigation/react-navigation/issues/11483

fukemy commented 1 year ago

any solution now?

vksgautam1986 commented 1 year ago

is there any way we can stick to v2 as v3 have lot of conflicts with other packages

tomekzaw commented 1 year ago

v3 have lot of conflicts with other packages

@vksgautam1986 what exactly seems to be the problem?

any solution now?

you can upgrade to Reanimated 3.4.1 now

agusvazquez commented 1 year ago

Thanks @tomekzaw

I have tested 3.4.1 and still having the same issue when using react navigation on web with the permanent drawer.

useAnimatedStyle.ts:429 Uncaught Error: useAnimatedStyle was used without a dependency array or Babel plugin. Please explicitly pass a dependency array, or enable the Babel/SWC plugin.

https://github.com/react-navigation/react-navigation/issues/11483

Also created a PR on react navigation but nobody is reviewing it. https://github.com/react-navigation/react-navigation/pull/11496

Is there anything we can do on react-native-reanimated library side?

Cheers

AlexanderEggers commented 1 year ago

@tomekzaw I'm aware that supporting v2 for 0.72 is quite an effort but I believe there are still quite a bit of issues around v3 which will block upgrading v3 for quite some time.. I found another two blocking issues since my last reported issue which I still need to find the time to provide with example projects.. These range from random reanimated related crashes to blank screens when navigating between certain screens in my project.

aphillipo commented 1 year ago

I am also having this problem and it will likely prevent me from updating to react-native 0.72.3 until this can be fixed! I don't think updating to v3 is practical but I can try.

powerpivar commented 1 year ago

also stacked because of react-native-vision-camera.

agusvazquez commented 1 year ago

Any news on this? Still waiting for this fix to be able to update to 0.72 :(

mikaelsn commented 1 year ago

Same issue here

darix795 commented 1 year ago

Simply changing the dialect fixes the issue image

I can confirm this does fix it. Only issue is when you have a remote CI server that does a pod install it can't change the pod file dialect. Can this be a minor release just to change this? In my project I'm also using is vision-camera

The fix for iOS should be on version v2.17.0

# RNReanimated.podspec

  s.pod_target_xcconfig = {
    "USE_HEADERMAP" => "YES",
    "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_TARGET_SRCROOT)\" \"$(PODS_ROOT)/#{folly_prefix}Folly\" \"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/Headers/Private/React-Core\" ",
    "FRAMEWORK_SEARCH_PATHS" => "\"${PODS_CONFIGURATION_BUILD_DIR}/React-hermes\"",
    "CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
  }

This work for me. patch-package generate this diff file:

diff --git a/node_modules/react-native-reanimated/RNReanimated.podspec b/node_modules/react-native-reanimated/RNReanimated.podspec
index 1cbeafc..1db5841 100644
--- a/node_modules/react-native-reanimated/RNReanimated.podspec
+++ b/node_modules/react-native-reanimated/RNReanimated.podspec
@@ -40,6 +40,7 @@ Pod::Spec.new do |s|
     "USE_HEADERMAP" => "YES",
     "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_TARGET_SRCROOT)\" \"$(PODS_ROOT)/#{folly_prefix}Folly\" \"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/Headers/Private/React-Core\" ",
     "FRAMEWORK_SEARCH_PATHS" => "\"${PODS_CONFIGURATION_BUILD_DIR}/React-hermes\"",
+    "CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
   }
   s.compiler_flags = folly_compiler_flags + ' ' + boost_compiler_flags
   s.xcconfig               = {

Anyone can add and use for fix temporary this issue.

numsu commented 1 year ago

In any case, we still plan to publish 2.x updates along with new 3.x releases and we commit to do so for at least a couple more versions, so there is no reason to feel abandoned.

I do feel a bit abandoned right now.

It has been only a year, many packages are still having issues with v3 and this will be a blocker for all of the users of those packages who are wishing to upgrade to >= RN 0.72.

tomekzaw commented 1 year ago

Hey @numsu

many packages are still having issues with v3

Could you please specify which packages exactly do you mean? We'll make sure they can migrate to Reanimated v3.

lexer commented 1 year ago

react-native-vision-camera doesn't work with Reanimated v3 and block the upgrade for many

tomekzaw commented 1 year ago

@lexer Thanks for the response. We're actively working on it. Reanimated 3.5.0 will expose API that RNVisionCamera v2/v3 will use for frame processors. Any other libraries?

Nox04 commented 1 year ago

@tomekzaw This carousel library is blocking some of our projects too: https://github.com/dohooo/react-native-reanimated-carousel

Should the fix you're working on, work for it too?

tomekzaw commented 1 year ago

@Nox04 What exactly seems to be the blocker? It looks like react-native-reanimated-carousel uses Reanimated 2 API which is essentially the same as in Reanimated v3. Do you have some error message that you can paste here?

Nox04 commented 1 year ago

@tomekzaw I wasn't aware of that. I'll try to use the carousel library with reanimated 3 and see if that works. Thanks for the answer!

dmackinn commented 1 year ago

The frame processor issue also blocks me from upgrading my projects. Using this alongside react-native-vision-camera and vision-camera-code-scanner

1fabiopereira commented 1 year ago

@lexer Thanks for the response. We're actively working on it. Reanimated 3.5.0 will expose API that RNVisionCamera v2/v3 will use for frame processors. Any other libraries?

Are there any expectations or predictions of how soon this will be available?

piaskowyk commented 1 year ago

Everything is ready from our side, we just preparing for the release - most probably next week.

bneigher commented 1 year ago

🙏

ikurowski commented 1 year ago

any updates?