Skip to content

Commit

Permalink
Add build script to check that codegen run properly in the project (#…
Browse files Browse the repository at this point in the history
…43105)

Summary:
Pull Request resolved: #43105

This is a quality of like improvement for the project we create for the final users.
Codegen generates code in `rncore`, within `node_modules`. This is not the perfect approach but it is working so far.

To make it more robust, we added a small script in React-Fabric podspec to check that codegen run properly when building.
In this way, if a user run `yarn install` and, for any reason, react-native is regenerated, we can provide a better DevX to our users with an actionable message on how to fix the build problem.

##Changelog
[iOS][Added] - Add error message if codegen has not run properly

Reviewed By: cortinico

Differential Revision: D53927788

fbshipit-source-id: a01a33086e4a0a1b0ada6c83283a5fd3fb5ee3eb
  • Loading branch information
cipolleschi authored and facebook-github-bot committed Feb 20, 2024
1 parent c02e83c commit 10edb9f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/react-native/ReactCommon/React-Fabric.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -292,4 +292,20 @@ Pod::Spec.new do |s|
ss.header_dir = "react/renderer/leakchecker"
ss.pod_target_xcconfig = { "GCC_WARN_PEDANTIC" => "YES" }
end

s.script_phases = [
{
:name => '[RN]Check rncore',
:execution_position => :before_compile,
:script => <<-EOS
echo "Checking whether Codegen has run..."
rncorePath="$REACT_NATIVE_PATH/ReactCommon/react/renderer/components/rncore"
if [[ ! -d "$rncorePath" ]]; then
echo 'error: Codegen did not run properly in your project. Please reinstall cocoapods with `bundle exec pod install`.'
exit 1
fi
EOS
}
]
end

0 comments on commit 10edb9f

Please sign in to comment.