expo-monorepo-example icon indicating copy to clipboard operation
expo-monorepo-example copied to clipboard

Invalid `Podfile` file: [codegen] Could not find react-native-codegen

Open 8times4 opened this issue 9 months ago • 8 comments

Description of the bug

Wrong path for reactNativePath

To Reproduce

What steps did you perform which led to this issue?

  1. Go to apps/mobile
  2. run npx expo prebuild -p ios
  3. Get the error.

Expected behavior

prebuild to pass.

Actual behavior

✔ Created native project | gitignore skipped
✔ Updated package.json and added index.js entry point for iOS and Android
› Installing using pnpm
> pnpm install
✔ Config synced
⚠️  Something went wrong running `pod install` in the `ios` directory.
Command `pod install` failed.
└─ Cause: Invalid `Podfile` file: [codegen] Could not find react-native-codegen..

 #  from /Users/8x4/expo-monorepo-example/apps/mobile/ios/Podfile:50
 #  -------------------------------------------
 #  
 >    use_react_native!(
 #      :path => config[:reactNativePath],
 #  -------------------------------------------

Additional context

Podfile use_react_native! func:

  use_react_native!(
    :path => config[:reactNativePath],
    :hermes_enabled => podfile_properties['expo.jsEngine'] == nil || podfile_properties['expo.jsEngine'] == 'hermes',
    :fabric_enabled => flags[:fabric_enabled],
    # An absolute path to your application root.
    :app_path => "#{Pod::Config.instance.installation_root}/..",
    # Note that if you have use_frameworks! enabled, Flipper will not work if enabled
    :flipper_configuration => flipper_config
  )

if :path => config[:reactNativePath], is replaced with :path => "../../../node_modules/react-native" then it works, even though react-native exists in my node_modules within apps/mobile.


(base) ➜  react-native git:(main) ✗ pwd
/Users/8x4/expo-monorepo-example/apps/mobile/node_modules/react-native

I have tried with both @react-native/codegen and react-native-codegen, they're defined as deps in apps/mobile/package.json the package only exists in the root node_modules, not in the apps/mobile/node_modules

I'm using an M1 Mac.

Thank you, 8x4

8times4 avatar Sep 22 '23 13:09 8times4

My team has also been experiencing this error lately, and it's been a major blocker. I just did a fresh clone of this repo, installed dependencies, navigated to the mobile directory, tried to run the app, and got this error.

Environment

node: 18.16.0
pnpm: 8.6.12

Steps

git clone [email protected]:byCedric/expo-monorepo-example.git
cd expo-monorepo-example
pnpm i
cd apps/mobile
npx expo run:ios

Error

CleanShot 2023-12-13 at 10 11 36@2x

makozlo avatar Dec 13 '23 16:12 makozlo

@8times4 did you find a solution? I got the same issue now.

enisze avatar Dec 28 '23 14:12 enisze

Same issue here. Haven't found a solution.

eabz avatar Dec 28 '23 19:12 eabz

Same issue here, didn't find a solution yet. I'm trying:

$ eas build -p ios --local

IJustDev avatar Jan 07 '24 16:01 IJustDev

It looks like there has been changes to pnpm setups in react-native: 0.72.8

https://github.com/facebook/react-native/commit/e70166a3a8b9ddf1a7e322db602c548aaa60102d#diff-766bef9361966fae97e56d95c694309a9e446f6ce5e8ea837b7d09b509e6a5b7

IJustDev avatar Jan 08 '24 12:01 IJustDev

Ok it looks like it worked by upgrading it to this. I think it's required that all of your react-native versions that are installed in every package has to be updated to 0.72.8.

I removed all node_modules folders and the package-lock.json files and ran npm install and after that pod install worked like expected.

My setup:

  • turbobuild (which uses npm workspaces under the hood afaik)

To check what versions are installed:

  • npm ls react-native

IJustDev avatar Jan 08 '24 12:01 IJustDev

I had the issue that my react-native-reanimaed package was not in the same folder as my react-native package. I solved it by adding it to the correspondig package.json.

enisze avatar Jan 08 '24 16:01 enisze

Provoqued by the previous comment, I was also not having react-native-codegen in the same folder as react-native. Using Yarn Berry and a monorepo, the fix for me was to add:

  "installConfig": {
    "hoistingLimits": "workspaces"
  }

to package.json of the workspace that uses expo/react-native.

nkalinov avatar Feb 04 '24 22:02 nkalinov

Hi all! Sorry for the extremely long delay! Next time, please do ping me on Twitter [@cedric_dev][https://x.com/cedric_dev].

This was indeed an issue with React Native. I just upgraded the monorepo to use Expo SDK 51 / React Native 0.74.1, meaning that you shouldn't run into this issue anymore.

The yarn/npm workarounds are super helpful, thanks for mentioning them!

Hope this helps!

byCedric avatar May 09 '24 12:05 byCedric