Skip to content

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

Closed

Description

@jbrowning

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

Activity

  1. added
    Repro providedA reproduction with a snippet of code, snack or repo is provided
    Platform: iOSThis issue is specific to iOS
    on Jun 1, 2023
  2. tomekzaw commented on Jun 2, 2023

    @tomekzaw
    Member

    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 🙏

  3. changed the title [-]iOS: Version 2.17.0 fails to built on React Native 0.72.0-rc.5[/-] [+]iOS: Version 2.17.0 fails to build on React Native 0.72.0-rc.5[/+] on Jun 2, 2023
  4. AlexanderEggers commented on Jun 20, 2023

    @AlexanderEggers
    Contributor

    @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.

  5. sylvainbaronnet commented on Jun 21, 2023

    @sylvainbaronnet

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

  6. tomekzaw commented on Jun 29, 2023

    @tomekzaw
    Member

    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?

  7. sylvainbaronnet commented on Jun 29, 2023

    @sylvainbaronnet

    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

  8. AlexanderEggers commented on Jun 29, 2023

    @AlexanderEggers
    Contributor

    @tomekzaw This is our current blocker: #4613 Everything else seems to run fine for us.

  9. tomekzaw commented on Jun 29, 2023

    @tomekzaw
    Member

    @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.

  10. tomekzaw commented on Jun 29, 2023

    @tomekzaw
    Member

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

  11. sylvainbaronnet commented on Jun 29, 2023

    @sylvainbaronnet

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

  12. sylvainbaronnet commented on Jun 30, 2023

    @sylvainbaronnet

    @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)

  13. camilossantos2809 commented on Jun 30, 2023

    @camilossantos2809
    Contributor

    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.

  14. 43 remaining items

  15. tomekzaw commented on Sep 14, 2023

    @tomekzaw
    Member

    @hemantgogia09 std::optional was introduced in C++17, can you confirm you're using it and not C++14? Which version of react-native are you using?

  16. hemantgogia09 commented on Sep 14, 2023

    @hemantgogia09

    @hemantgogia09 std::optional was introduced in C++17, can you confirm you're using it and not C++14? Which version of react-native are you using?

    i am using react-native 0.72.4. How do i check which C++ version am i using?

  17. hemantgogia09 commented on Sep 15, 2023

    @hemantgogia09

    @tomekzaw sorry for bump any guidance that you can give here? I am stuck without this upgrade.

  18. Romick2005 commented on Sep 18, 2023

    @Romick2005

    Hi @tomekzaw, I got this error running on latest [email protected], [email protected] and [email protected] that should support reanimated@V3. It works fine for iOS build, but fails on Android build.

    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':react-native-vision-camera:buildCMakeDebug[arm64-v8a]'.
    > com.android.ide.common.process.ProcessException: ninja: Entering directory `/Users/user/project/node_modules/react-native-vision-camera/android/.cxx/Debug/4s5y5b3c/arm64-v8a'
      [1/10] Building CXX object CMakeFiles/VisionCamera.dir/src/main/cpp/java-bindings/JHashMap.cpp.o
      [2/10] Building CXX object CMakeFiles/VisionCamera.dir/src/main/cpp/java-bindings/JImageProxy.cpp.o
      [3/10] Building CXX object CMakeFiles/VisionCamera.dir/src/main/cpp/java-bindings/JFrameProcessorPlugin.cpp.o
      [4/10] Building CXX object CMakeFiles/VisionCamera.dir/src/main/cpp/VisionCameraScheduler.cpp.o
      [5/10] Building CXX object CMakeFiles/VisionCamera.dir/src/main/cpp/VisionCamera.cpp.o
      [6/10] Building CXX object CMakeFiles/VisionCamera.dir/src/main/cpp/FrameHostObject.cpp.o
      [7/10] Building CXX object CMakeFiles/VisionCamera.dir/src/main/cpp/JSIJNIConversion.cpp.o
      FAILED: CMakeFiles/VisionCamera.dir/src/main/cpp/JSIJNIConversion.cpp.o 
      /Users/user/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ --target=aarch64-none-linux-android21 --sysroot=/Users/user/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/sysroot -DVisionCamera_EXPORTS -I/Users/user/project/node_modules/react-native/ReactAndroid/src/main/jni/react/turbomodule -I/Users/user/project/node_modules/react-native/ReactCommon -I/Users/user/project/node_modules/react-native/ReactCommon/callinvoker -I/Users/user/project/node_modules/react-native/ReactCommon/jsi -I/Users/user/project/node_modules/react-native/ReactCommon/react/renderer/graphics/platform/cxx -I/Users/user/project/node_modules/react-native/ReactCommon/runtimeexecutor -I/Users/user/project/node_modules/react-native/ReactCommon/yoga -I/Users/user/project/node_modules/react-native-vision-camera/android/src/main/cpp -isystem /Users/user/.gradle/caches/transforms-3/00f2500bc865ce1c87c6a8f62f269c59/transformed/jetified-hermes-android-0.72.4-debug/prefab/modules/libhermes/include -isystem /Users/user/.gradle/caches/transforms-3/53f4b2980c6436229b017cee53292244/transformed/jetified-react-android-0.72.4-debug/prefab/modules/folly_runtime/include -isystem /Users/user/.gradle/caches/transforms-3/53f4b2980c6436229b017cee53292244/transformed/jetified-react-android-0.72.4-debug/prefab/modules/glog/include -isystem /Users/user/.gradle/caches/transforms-3/53f4b2980c6436229b017cee53292244/transformed/jetified-react-android-0.72.4-debug/prefab/modules/jsi/include -isystem /Users/user/.gradle/caches/transforms-3/53f4b2980c6436229b017cee53292244/transformed/jetified-react-android-0.72.4-debug/prefab/modules/reactnativejni/include -isystem /Users/user/.gradle/caches/transforms-3/eeb7a76cc0d2c5a8cc81cab965bba0b1/transformed/jetified-fbjni-0.3.0/prefab/modules/fbjni/include -isystem /Users/user/project/node_modules/react-native-reanimated/android/build/prefab-headers/reanimated -fexceptions -frtti -std=c++1y -DONANDROID -DFOR_HERMES=1 -g  -fno-limit-debug-info -fPIC -DFOLLY_NO_CONFIG=1 -DFOLLY_HAVE_CLOCK_GETTIME=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_MOBILE=1 -DFOLLY_HAVE_RECVMMSG=1 -DFOLLY_HAVE_PTHREAD=1 -DFOLLY_HAVE_XSI_STRERROR_R=1 -MD -MT CMakeFiles/VisionCamera.dir/src/main/cpp/JSIJNIConversion.cpp.o -MF CMakeFiles/VisionCamera.dir/src/main/cpp/JSIJNIConversion.cpp.o.d -o CMakeFiles/VisionCamera.dir/src/main/cpp/JSIJNIConversion.cpp.o -c /Users/user/project/node_modules/react-native-vision-camera/android/src/main/cpp/JSIJNIConversion.cpp
      In file included from /Users/user/project/node_modules/react-native-vision-camera/android/src/main/cpp/JSIJNIConversion.cpp:17:
      /Users/user/.gradle/caches/transforms-3/53f4b2980c6436229b017cee53292244/transformed/jetified-react-android-0.72.4-debug/prefab/modules/reactnativejni/include/react/jni/ReadableNativeMap.h:41:3: error: no template named 'optional' in namespace 'std'; did you mean 'folly::Optional'?
        std::optional<folly::dynamic> keys_;
        ^~~~~
      /Users/user/.gradle/caches/transforms-3/53f4b2980c6436229b017cee53292244/transformed/jetified-react-android-0.72.4-debug/prefab/modules/folly_runtime/include/folly/Optional.h:102:7: note: 'folly::Optional' declared here
      class Optional {
            ^
      1 error generated.
      [8/10] Building CXX object CMakeFiles/VisionCamera.dir/src/main/cpp/FrameProcessorRuntimeManager.cpp.o
      [9/10] Building CXX object CMakeFiles/VisionCamera.dir/src/main/cpp/CameraView.cpp.o
      ninja: build stopped: subcommand failed.
      
      C++ build system [build] failed while executing:
          /Users/user/Library/Android/sdk/cmake/3.22.1/bin/ninja \
            -C \
            /Users/user/project/node_modules/react-native-vision-camera/android/.cxx/Debug/4s5y5b3c/arm64-v8a \
            VisionCamera
        from /Users/user/project/node_modules/react-native-vision-camera/android
    
  19. Romick2005 commented on Sep 19, 2023

    @Romick2005

    Just checked latest [email protected] and [email protected] and it works for me!
    Thank you @tomekzaw for updating C++14 to C++17!

  20. Skizu commented on Sep 19, 2023

    @Skizu

    Using JSC and/or having an application minSdkVersion of anything but 21 (i.e. 24 for react-native-webrtc) results in build failures.

    It appears that if hermes is disabled react-native-reanimated's build.gradle still evaluates FOR_HERMES to true.

  21. UlisesGallardo commented on Sep 19, 2023

    @UlisesGallardo

    For me it is still not working with [email protected] and [email protected] and [email protected] , similar to @Romick2005 , but I tried with [email protected] and it worked

  22. UlisesGallardo commented on Sep 19, 2023

    @UlisesGallardo

    Even if it works with [email protected] , I have another problem: ERROR Error: Reanimated V3 is not installed, Frame Processors are not available!, js engine: hermes

    For me it is still not working with [email protected] and [email protected] and [email protected] , similar to @Romick2005 , but I tried with [email protected] and it worked

  23. Skizu commented on Sep 27, 2023

    @Skizu

    Bump

  24. piaskowyk commented on Sep 28, 2023

    @piaskowyk
    Member

    To sum up:

  25. TarifEzaz commented on Oct 18, 2023

    @TarifEzaz

    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",
      }

    How this can be done?

  26. CelinaJa commented on Nov 8, 2023

    @CelinaJa

    any updates?

    1. Upgrade Reanimated to 3.5.1
    yarn add react-native-reanimated@^3.5.1
    1. Install RNVisionCamera from this PR: feat: Reanimated v3 support in RNVisionCamera v2 mrousavy/react-native-vision-camera#1759
    yarn add tomekzaw/react-native-vision-camera#e323a61d360ba70d30ecf8522e515a6270225db0
    1. Don't forget to run pod install and yarn start --reset-cache.

    For me, this resulted in error Couldn't find match for "e323a61d360ba70d30ecf8522e515a6270225db0"
    Using yarn add tomekzaw/react-native-vision-camera#refs/heads/v2 instead worked for me! Probably because the PR has been merged.

  27. tomekzaw commented on Nov 8, 2023

    @tomekzaw
    Member

    @CelinaJa The PR was merged so you can use [email protected].

  28. aliustaoglu commented on Jan 30, 2024

    @aliustaoglu

    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",
      }

    How this can be done?

    You gotta do this in node_modules/react-native-reanimated/RNReanimated.podspec. And then patch the package so that it will be re-applied whenever you do a new yarn install. I can confirm this way works.

    npx patch-package react-native-reanimated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs reviewIssue is ready to be reviewed by a maintainerPlatform: iOSThis issue is specific to iOSRepro providedA reproduction with a snippet of code, snack or repo is provided

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions