Replies: 3 comments
-
Note: You can also take a look at this file from react-native-builder-bob that patches the example React Native application to invoke codegen before native builds. |
Beta Was this translation helpful? Give feedback.
-
The |
Beta Was this translation helpful? Give feedback.
-
My 2c here: Gradle/CocoaPods already offer this level of configurability. I don't think this should be exposed via the CLI as it's too broad and generic and potentially hard to maintain for CLI developers in the long run |
Beta Was this translation helpful? Give feedback.
-
It would be handy to have a way in the Community CLI to run arbitrary commands in native build steps. The build steps here can be pre-build and post-build for starters.
Ideally, the commands should be called regardless of the build method being used i.g. using the XCode App or the Android Studio App, running
yarn android
, oryarn ios
, usingxcodebuild
orgradlew
via the terminal.A good example here would be with React Native libraries. When a library author opts in to ship the codegen-generated code with their library (more details in this document), codegen doesn't run for their libraries during the build process anymore. This is the desired behavior when the author ships their library however this can cause issues in the development process. If the author updates their codegen specs without calling codegen, their native app would build just fine on their end. However, when they ship their code, consumers would have trouble building the library on their end. With a way to hook into the native build process, the library author can call the codegen whenever they build their app, verifying their codegen-generated code is up-to-date.
How can React Native apps specify their build hooks?
One way of doing this would be adding a new property to the project section of the React Native configuration.
project.ios.preBuild
,project.ios.postBuild
,project.android.preBuild
, andproject.android.postBuild
with string values can be added and their values would be called during appropriate build stages.Possible Issues
pre-build
step to generate some library code (like invoking codegen), the build will fail sincepod installs
would be called before having the generated files, therefore those files wouldn't be captured by CocoaPods. It's possible to add apre_install
step to CocoaPods but this is not a part of the native build.Beta Was this translation helpful? Give feedback.
All reactions