Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codegen page lacks info and is confusing #4460

Open
ospfranco opened this issue Jan 24, 2025 · 1 comment
Open

Codegen page lacks info and is confusing #4460

ospfranco opened this issue Jan 24, 2025 · 1 comment

Comments

@ospfranco
Copy link

ospfranco commented Jan 24, 2025

Description

I have a RN library that was shipping the generated artifacts using RN 0.76. When I tried to add it to a RN 75 I started getting this compilation error:

Image

This is confusing as it is on the generated code. I stumbled for hours trying to re-generate everything but nothing helped. I then tried to update the app to 76 and it magically started working. I tried to revert back to 75 but it kept working.

I then started googling trying to see if the problem was my package and gratuitously landed on this page

https://reactnative.dev/docs/the-new-architecture/codegen-cli#including-generated-code-into-libraries

It finally dawned on me I had the "includesGeneratedCode": true set. This is the default used by react-native-builder-bob. So, I was shipping the generated code which, contrary to what's described on that page, it cannot be true to be guaranteed stable across RN versions. What's the entire point of codegen if it will be generated against one specific version?!

I'm on the process of disabling the flag and shipping only the source files so codegen happens on build time of the app but I'm just trying to understand if I'm holding it wrong or what's mentioned on the page is just not true

I don't know if you can confidently ship this feature. I know it's not necessarily fault of the codegen cli but rather the template but at least to me it seems stability across versions CANNOT be guaranteed, right?

@ospfranco
Copy link
Author

ospfranco commented Jan 24, 2025

The other problem I have is now, the instructions to disable this read:

Update your package.json to include the generated code.
Update your podspec to include the generated code.
Update your build.Gradle file to include the generated code.
Update cmakeListsPath in react-native.config.js so that Gradle doesn't look for CMakeLists file in the build directory but instead in your outputDir.

Uhm... update to what exactly? What do I need to put on react-native-config.js? Leave it empty? And the podspec? And build.gradle?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant