react-native-quick-crypto icon indicating copy to clipboard operation
react-native-quick-crypto copied to clipboard

'base64.h' file not found in MGLUtils.cpp

Open akinzalowevidation opened this issue 1 year ago • 31 comments

After upgrading to 0.7.0-rc.2 I am receiving the following error when building iOS through eas:

[RUN_FASTLANE] › Compiling react-native-quick-crypto Pods/react-native-quick-crypto » MGLUtils.cpp
[RUN_FASTLANE] 
❌  (node_modules/react-native-quick-crypto/cpp/Utils/MGLUtils.cpp:9:10)

   7 | #include <string>
   8 | 
>  9 | #include "base64.h"
     |          ^ 'base64.h' file not found
  10 | 
  11 | #ifdef ANDROID
  12 | #include "JSIUtils/MGLJSIMacros.h"

Here are the relevant package versions in my package.json:

"expo": "~50.0.14",
"react-native": "0.73.6",
"react-native-quick-base64": "^2.1.2",
"react-native-quick-crypto": "0.7.0-rc.2",

akinzalowevidation avatar Apr 30 '24 16:04 akinzalowevidation

Under the android folder, CMakeLists.txt

The include directories needs to be updated to:

include_directories(
  "../../../node_modules/react-native-quick-base64/cpp"
)

pehkay avatar May 01 '24 08:05 pehkay

Is that Expo-specific?

If you have properly installed RNQC deps, there should be a RNQB64 folder in node_modules one directory up from ./android, not three (i.e. in your app).

boorad avatar May 01 '24 13:05 boorad

Is that Expo-specific?

@boorad Yes, a managed Expo application. We were previously on 0.6.1 with no issues until issue #241 started happening. I don't think downgrading OpenSSL, the alternate solution suggested in that issue, will work in the long term because of the issue described here.

akinzalowevidation avatar May 01 '24 14:05 akinzalowevidation

I get that, and I am suggesting use the release candidates, not downgrade. But why does Expo need the extra ../../ on your include_directories paths? If dependencies are installed properly, that shouldn't be the case. That's what I don't understand. But I don't use Expo.

boorad avatar May 01 '24 14:05 boorad

I get that, and I am suggesting use the release candidates, not downgrade. But why does Expo need the extra ../../ on your include_directories paths? If dependencies are installed properly, that shouldn't be the case. That's what I don't understand. But I don't use Expo.

That was @pehkay's solution above for Android. That is not a solution I can implement though, since it is a managed Expo application so the native ios and android folders and code are not available to edit. I had not yet tested Android when creating this issue, but after just trying to build it I am getting the same error:

[RUN_GRADLEW]   /private/var/folders/t8/qqvt248d71l8td83wd3ksr8c0000gp/T/eas-build-local-nodejs/97c49f93-05be-44bc-9f82-f3aa3d0b1ddc/build/node_modules/react-native-quick-crypto/cpp/Utils/MGLUtils.cpp:9:10: fatal error: 'base64.h' file not found
[RUN_GRADLEW]   #include "base64.h"
[RUN_GRADLEW]            ^~~~~~~~~~
[RUN_GRADLEW]   1 error generated.

akinzalowevidation avatar May 01 '24 14:05 akinzalowevidation

Is that Expo-specific?

If you have properly installed RNQC deps, there should be a RNQB64 folder in node_modules one directory up from ./android, not three (i.e. in your app).

No. I am not using Expo. The workaround I posted is just an, well, to give an indicator of source of the Android compilation error.

It seems that cmake's INCLUDES is using the android folder as its working folder. C:/Projects/xxxx/node_modules/react-native-quick-crypto/android/

INCLUDES = -IC:/Projects/xxxx/node_modules/react-native-quick-crypto/android/../node_modules/react-native-quick-base64/cpp

The above doesn't work because it is looking for the nodes_modules folder in /react-native-quick-crypto

INCLUDES = -IC:/Projects/xxxx/node_modules/react-native-quick-crypto/android/../../../node_modules/react-native-quick-base64/cpp

This does.

pehkay avatar May 02 '24 01:05 pehkay

I noticed that the other INCLUDES are not being included (is it only in Window environment)?

I will suggest to change to below or something equivalent ... (as I am a C++ noob).

set(NODE_MODULES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../node_modules")

....

include_directories( "${NODE_MODULES_DIR}/react-native-quick-base64/cpp" )

Just like you have used ${NODE_MODULES_DIR} in target_includes. Because they aren't included really. But it still works :)

target_include_directories( ${PACKAGE_NAME} PRIVATE "../cpp" "src/main/cpp" "${NODE_MODULES_DIR}/react-native/ReactCommon" "${NODE_MODULES_DIR}/react-native/ReactCommon/callinvoker" "${NODE_MODULES_DIR}/react-native/ReactAndroid/src/main/jni/react/turbomodule" "${NODE_MODULES_DIR}/react-native/ReactCommon/jsi" "${NODE_MODULES_DIR}/react-native/ReactCommon/turbomodule/core" "${NODE_MODULES_DIR}/react-native/ReactCommon/react/nativemodule/core" )

pehkay avatar May 02 '24 01:05 pehkay

Can you throw together a PR, please? I'll pull it down and test from my side, and see if this improves our build story.

boorad avatar May 02 '24 01:05 boorad

Can you throw together a PR, please? I'll pull it down and test from my side, and see if this improves our build story.

https://github.com/margelo/react-native-quick-crypto/pull/297

pehkay avatar May 02 '24 01:05 pehkay

I have the same issue on react-native 0.74.0. iOS.

Doko-Demo-Doa avatar May 02 '24 02:05 Doko-Demo-Doa

I get the same issue on iOS 0.7.0-rc.4, and RN 0.74.0 new architecture enabled I tried pasting the package RNQB64 folder in node_modules inside RNQC so that the path in podspec source_files matches "node_modules/react-native-quick-base64/cpp/base64.h" but it still failed with 'base64.h' file not found, have not tried android build yet

ansumanshah avatar May 02 '24 04:05 ansumanshah

I fixed this using the latest version of react-native-quick-base64 , I'm using [email protected]

DavideSegullo avatar May 03 '24 11:05 DavideSegullo

using react-native-quick-base64 2.1.2 and thats the latest version, still doesnt work

ansumanshah avatar May 03 '24 11:05 ansumanshah

Given that react native 0.74.0 now has native atob and btoa, should we still have react-native-quick-base64 in here?

shamilovtim avatar May 04 '24 04:05 shamilovtim

@pehkay can you pull the branch from #303 and try that instead of your PR? @shamilovtim helped me find what is hopefully the original culprit and a good fix for it.

EDIT: that is, test it after I fix the PR. It built locally, but not in Github actions.

boorad avatar May 06 '24 01:05 boorad

Given that react native 0.74.0 now has native atob and btoa, should we still have react-native-quick-base64 in here?

I think so, for at least a little while. Maybe see if they are present and use them, otherwise use RNQB64.

boorad avatar May 06 '24 01:05 boorad

@pehkay can you pull the branch from #303 and try that instead of your PR? @shamilovtim helped me find what is hopefully the original culprit and a good fix for it.

EDIT: that is, test it after I fix the PR. It built locally, but not in Github actions.

Ok. I tried your branch. There needs to be a fix as the arguments are causing error in gradle build (windows) :

    externalNativeBuild {
      cmake {
        cppFlags "-O2 -frtti -fexceptions -Wall -Wno-unused-variable -fstack-protector-all"
        arguments "-DANDROID_STL=c++_shared", 
                  "-DNODE_MODULES_DIR=" + nodeModules
        abiFilters (*reactNativeArchitectures())
      }
    }

Other than that, it looks good :)

pehkay avatar May 06 '24 04:05 pehkay

arguments are causing error in gradle build (windows)

This SO article seems to show that it looks correct. Maybe add a println "nodeModules: ${nodeModules}" line somewhere to check the value is what you'd expect? What is the error?

I want to get this right for Windows too 🖖

boorad avatar May 06 '24 13:05 boorad

arguments are causing error in gradle build (windows)

This SO article seems to show that it looks correct. Maybe add a println "nodeModules: ${nodeModules}" line somewhere to check the value is what you'd expect? What is the error?

I want to get this right for Windows too 🖖

Just ignore me. The "nodeModules: ${nodeModules}" should works in groovy.

Weird, that I might have pull the wrong commit down. My yarn pulls the code with:

arguments '-DANDROID_STL=c++_shared' , "-DNODE_MODULES_DIR=${nodeModules}",

And punctuation matters. It should be as below: (I did check your branch in github).

arguments "-DANDROID_STL=c++_shared" , "-DNODE_MODULES_DIR=${nodeModules}",

pehkay avatar May 06 '24 14:05 pehkay

No, the comma on the end should not be there. It throws an error about String vs List.

You may have pulled it before I took that comma out. Also, be sure to gradle clean or equivalent on your platform. It helped me catch issues.

boorad avatar May 06 '24 15:05 boorad

@boorad Does #303 also fix this issue for iOS?

akinzalowevidation avatar May 06 '24 15:05 akinzalowevidation

@boorad Does #303 also fix this issue for iOS?

The example app builds locally for me, and CI says it works... give it a whirl.

But nothing should have changed for iOS in #303.

Last change for iOS was this.

boorad avatar May 06 '24 16:05 boorad

Confirmed that it not work on pure [email protected] with react-native-quick-base64@^2.1.2, react-native-quick-crypto@^0.7.0-rc.4 on iOS

/node_modules/react-native-quick-crypto/cpp/Utils/MGLUtils.cpp:9:10: fatal error: 'base64.h' file not found
#include "base64.h"
         ^~~~~~~~~~
4 warnings and 1 error generated.

longnguyen2508 avatar May 07 '24 03:05 longnguyen2508

Confirmed that it not work on pure [email protected] with react-native-quick-base64@^2.1.2, react-native-quick-crypto@^0.7.0-rc.4 on iOS


/node_modules/react-native-quick-crypto/cpp/Utils/MGLUtils.cpp:9:10: fatal error: 'base64.h' file not found

#include "base64.h"

         ^~~~~~~~~~

4 warnings and 1 error generated.

Can you add reanimated and see if that fixes your problem?

shamilovtim avatar May 07 '24 14:05 shamilovtim

Confirmed that it not work on pure [email protected] with react-native-quick-base64@^2.1.2, react-native-quick-crypto@^0.7.0-rc.4 on iOS

/node_modules/react-native-quick-crypto/cpp/Utils/MGLUtils.cpp:9:10: fatal error: 'base64.h' file not found

#include "base64.h"

         ^~~~~~~~~~

4 warnings and 1 error generated.

Can you add reanimated and see if that fixes your problem?

Does not work for me following these steps: https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/getting-started/#step-1-install-the-package

I have the same setup as @longnguyen2508, essentially trying to run the package on a fresh react native install.

pandisFox avatar May 07 '24 15:05 pandisFox

Confirmed that it not work on pure [email protected] with react-native-quick-base64@^2.1.2, react-native-quick-crypto@^0.7.0-rc.4 on iOS

/node_modules/react-native-quick-crypto/cpp/Utils/MGLUtils.cpp:9:10: fatal error: 'base64.h' file not found

#include "base64.h"

     ^~~~~~~~~~

4 warnings and 1 error generated.

Can you add reanimated and see if that fixes your problem?

Does not work for me following these steps: https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/getting-started/#step-1-install-the-package

I have the same setup as @longnguyen2508, essentially trying to run the package on a fresh react native install.

But to be clear using Expo fixes the issues right?

shamilovtim avatar May 07 '24 15:05 shamilovtim

Confirmed that it not work on pure [email protected] with react-native-quick-base64@^2.1.2, react-native-quick-crypto@^0.7.0-rc.4 on iOS

/node_modules/react-native-quick-crypto/cpp/Utils/MGLUtils.cpp:9:10: fatal error: 'base64.h' file not found

#include "base64.h"

     ^~~~~~~~~~

4 warnings and 1 error generated.

Can you add reanimated and see if that fixes your problem?

Does not work for me following these steps: https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/getting-started/#step-1-install-the-package I have the same setup as @longnguyen2508, essentially trying to run the package on a fresh react native install.

But to be clear using Expo fixes the issues right?

I'm not using expo (on my actual project, yes but this fresh install is just bare RN). I should say this is now working on iOS at least locally in dev but I can' tell why - as far as Android still getting the same error.

  /Users/x/node_modules/react-native-quick-crypto/cpp/Utils/MGLUtils.cpp:9:10: fatal error: 'base64.h' file not found
  #include "base64.h"
           ^~~~~~~~~~
  1 error generated.
  ninja: build stopped: subcommand failed.
  
  C++ build system [build] failed while executing:
      /Users/x/Library/Android/sdk/cmake/3.22.1/bin/ninja \
        -C \
        /Users/x//node_modules/react-native-quick-crypto/android/.cxx/Debug/51zm2n4k/arm64-v8a \
        reactnativequickcrypto
    from /Users/x/node_modules/react-native-quick-crypto/android

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

BUILD FAILED in 4s
error Failed to install the app. Command failed with exit code 1: ./gradlew app:installDebug -PreactNativeDevServerPort=8081 FAILURE: Build failed with an exception. * What went wrong:
Execution failed for task ':react-native-quick-crypto:buildCMakeDebug[arm64-v8a]'

pandisFox avatar May 07 '24 18:05 pandisFox

Confirmed that it not work on pure [email protected] with react-native-quick-base64@^2.1.2, react-native-quick-crypto@^0.7.0-rc.4 on iOS

/node_modules/react-native-quick-crypto/cpp/Utils/MGLUtils.cpp:9:10: fatal error: 'base64.h' file not found

#include "base64.h"

     ^~~~~~~~~~

4 warnings and 1 error generated.

Can you add reanimated and see if that fixes your problem?

Does not work for me following these steps: https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/getting-started/#step-1-install-the-package I have the same setup as @longnguyen2508, essentially trying to run the package on a fresh react native install.

But to be clear using Expo fixes the issues right?

I'm not using expo (on my actual project, yes but this fresh install is just bare RN). I should say this is now working on iOS at least locally in dev but I can' tell why - as far as Android still getting the same error.

  /Users/x/node_modules/react-native-quick-crypto/cpp/Utils/MGLUtils.cpp:9:10: fatal error: 'base64.h' file not found
  #include "base64.h"
           ^~~~~~~~~~
  1 error generated.
  ninja: build stopped: subcommand failed.
  
  C++ build system [build] failed while executing:
      /Users/x/Library/Android/sdk/cmake/3.22.1/bin/ninja \
        -C \
        /Users/x//node_modules/react-native-quick-crypto/android/.cxx/Debug/51zm2n4k/arm64-v8a \
        reactnativequickcrypto
    from /Users/x/node_modules/react-native-quick-crypto/android

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

BUILD FAILED in 4s
error Failed to install the app. Command failed with exit code 1: ./gradlew app:installDebug -PreactNativeDevServerPort=8081 FAILURE: Build failed with an exception. * What went wrong:
Execution failed for task ':react-native-quick-crypto:buildCMakeDebug[arm64-v8a]'

I don't understand. You said it didn't work after adding reanimated. What changed?

If you remove reanimated, does it stop building?

shamilovtim avatar May 07 '24 18:05 shamilovtim

Confirmed that it not work on pure [email protected] with react-native-quick-base64@^2.1.2, react-native-quick-crypto@^0.7.0-rc.4 on iOS

/node_modules/react-native-quick-crypto/cpp/Utils/MGLUtils.cpp:9:10: fatal error: 'base64.h' file not found

#include "base64.h"

     ^~~~~~~~~~

4 warnings and 1 error generated.

Can you add reanimated and see if that fixes your problem?

Does not work for me following these steps: https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/getting-started/#step-1-install-the-package I have the same setup as @longnguyen2508, essentially trying to run the package on a fresh react native install.

But to be clear using Expo fixes the issues right?

I'm not using expo (on my actual project, yes but this fresh install is just bare RN). I should say this is now working on iOS at least locally in dev but I can' tell why - as far as Android still getting the same error.

  /Users/x/node_modules/react-native-quick-crypto/cpp/Utils/MGLUtils.cpp:9:10: fatal error: 'base64.h' file not found
  #include "base64.h"
           ^~~~~~~~~~
  1 error generated.
  ninja: build stopped: subcommand failed.
  
  C++ build system [build] failed while executing:
      /Users/x/Library/Android/sdk/cmake/3.22.1/bin/ninja \
        -C \
        /Users/x//node_modules/react-native-quick-crypto/android/.cxx/Debug/51zm2n4k/arm64-v8a \
        reactnativequickcrypto
    from /Users/x/node_modules/react-native-quick-crypto/android

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

BUILD FAILED in 4s
error Failed to install the app. Command failed with exit code 1: ./gradlew app:installDebug -PreactNativeDevServerPort=8081 FAILURE: Build failed with an exception. * What went wrong:
Execution failed for task ':react-native-quick-crypto:buildCMakeDebug[arm64-v8a]'

I don't understand. You said it didn't work after adding reanimated. What changed?

If you remove reanimated, does it stop building?

No, it doesn't - its working with and without reanimated on the fresh RN install without expo. Just doesn't build on android and fails with the missing base64.h error (regardless of reanimated). That said considering I was successful in the fresh RN install with iOS I've now moved back to my actual project which uses expo and it runs on Android but it doesn't on iOS.... seemingly there's something to this but I have no idea what it is. Don't think theres any point in following my case any further - maybe others can provide a more reproducible case. Thanks @shamilovtim - I'll keep trying on my end and if I find something conclusive I'll share it.

pandisFox avatar May 07 '24 19:05 pandisFox

FYI, the android fix in #303 is not yet in a release candidate. You'd have to reference main in your package.json file to see if that solves android.

boorad avatar May 07 '24 19:05 boorad