react-native-keys icon indicating copy to clipboard operation
react-native-keys copied to clipboard

Monorepo config support

Open ishan-sharma-me opened this issue 11 months ago β€’ 4 comments

Behavior

  • Turbo monorepo using pnpm. node_modules are in the root directory, react-native project is in apps directory of the root directory.
  • Set up everything according to the instructions and changed the pre-actions script to point the node_modules
$NODE_BINARY "${SRCROOT}/../../../node_modules/react-native-keys/keysIOS.js"
  • build works but the tmp.xcconfig is generated in a ios folder in the root folder whereas it should be generated in apps/react-native-project/ios folder.
  • I think just exposing some env variable we can set in the pre-actions script will solve this

Platform

  • [x] Android
  • [X] iOS

ishan-sharma-me avatar Dec 16 '24 13:12 ishan-sharma-me

πŸ‘‹ @ishan-sharma-me Thanks for opening your issue here! If you find this package useful hit the star🌟!

github-actions[bot] avatar Dec 16 '24 13:12 github-actions[bot]

also getting this error while trying to build on android: rn 0.76.3

Configuration on demand is an incubating feature.

/bin/sh: /Users/flek/projects/flek/flek/apps/platform-ui/node_modules/react-native-keys/keysAndroid.js: No such file or directory

> Configure project :app
./keys.development.json
**************************
*** Missing KEYs file ****
**************************
android.packagingOptions.pickFirsts += [**/libcrypto.so] (1)
 ℹ️  Applying gradle plugin 'expo-dev-launcher-gradle-plugin' ([email protected])
  C++ build system [configure] failed while executing:
      /Users/flek/Library/Android/sdk/cmake/3.22.1/bin/cmake \
        -H/Users/flek/projects/flek/flek/node_modules/react-native-keys/android \
        -DCMAKE_SYSTEM_NAME=Android \
        -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
        -DCMAKE_SYSTEM_VERSION=24 \
        -DANDROID_PLATFORM=android-24 \
        -DANDROID_ABI=arm64-v8a \
        -DCMAKE_ANDROID_ARCH_ABI=arm64-v8a \
        -DANDROID_NDK=/Users/flek/Library/Android/sdk/ndk/26.1.10909125 \
        -DCMAKE_ANDROID_NDK=/Users/flek/Library/Android/sdk/ndk/26.1.10909125 \
        -DCMAKE_TOOLCHAIN_FILE=/Users/flek/Library/Android/sdk/ndk/26.1.10909125/build/cmake/android.toolchain.cmake \
        -DCMAKE_MAKE_PROGRAM=/Users/flek/Library/Android/sdk/cmake/3.22.1/bin/ninja \
        "-DCMAKE_CXX_FLAGS=-fexceptions -frtti -std=c++1y -DONANDROID" \
        -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/Users/flek/projects/flek/flek/node_modules/react-native-keys/android/build/intermediates/cxx/Debug/4c5q2n1j/obj/arm64-v8a \
        -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=/Users/flek/projects/flek/flek/node_modules/react-native-keys/android/build/intermediates/cxx/Debug/4c5q2n1j/obj/arm64-v8a \
        -DCMAKE_BUILD_TYPE=Debug \
        -DCMAKE_FIND_ROOT_PATH=/Users/flek/projects/flek/flek/node_modules/react-native-keys/android/.cxx/Debug/4c5q2n1j/prefab/arm64-v8a/prefab \
        -B/Users/flek/projects/flek/flek/node_modules/react-native-keys/android/.cxx/Debug/4c5q2n1j/arm64-v8a \
        -GNinja \
        -DANDROID_STL=c++_shared \
        -DNODE_MODULES_DIR=/Users/flek/projects/flek/flek/node_modules \
        -DREACT_NATIVE_MINOR_VERSION=76
    from /Users/flek/projects/flek/flek/node_modules/react-native-keys/android
  CMake Error at CMakeLists.txt:22 (add_library):
    Target "react-native-keys" links to target "ReactAndroid::reactnativejni"
    but the target was not found.  Perhaps a find_package() call is missing for
    an IMPORTED target, or an ALIAS target is missing?
  
  
  CMake Error at CMakeLists.txt:22 (add_library):
    Target "react-native-keys" links to target
    "ReactAndroid::react_nativemodule_core" but the target was not found.
    Perhaps a find_package() call is missing for an IMPORTED target, or an
    ALIAS target is missing?
  
  
  CMake Warning:
    Manually-specified variables were not used by the project:
  
      NODE_MODULES_DIR

ishan-sharma-me avatar Dec 16 '24 14:12 ishan-sharma-me

Did you find any solution ???

tejasjoshiagile avatar Dec 31 '24 11:12 tejasjoshiagile

I made a couple of edits to RNKeys.gradle to get this to work.

Digging into RNKeys.gradle it looks like there's two paths for fetching the key file -- one for RNKeys.gradle and another for keysAndroid.js

The one in RNKeys.gradle looks from {workspace root}/{react native app}/android/../${keyfile} The one in keysAndroid.js looks from {workspace root}/ -- monorepo bug.

Added this custom path for now and modified RNKeys.gradle: ln 68 + def keyFileMonorepoPathFix = safeExtGet("keyFileMonorepoPathFix", "") ln 73 - exportCommand = "set KEYSFILE=" + keysFile + " && node "; ln 73 + exportCommand = "set KEYSFILE=" + keyFileMonorepoPathFix + keysFile + " && node ";

ln 75 - exportCommand = "export KEYSFILE=" + keysFile + " && "; ln 75 + exportCommand = "export KEYSFILE=" + keyFileMonorepoPathFix + keysFile + " && ";

Then in app build.gradle, after setting the ext.keyFiles I added: project.ext.keyFileMonorepoPathFix = "{react native app}/"

Not sure if this is the best approach. Ideally would there be checks whether there's a monorepo in RNKeys.gradle and keysAndroid.js? Or something closer to how iOS does it where we can add our own customization per scheme?

lumenlunae avatar Aug 20 '25 02:08 lumenlunae