Skip to content

Commit

Permalink
Upgrade React Native 0.71.11 - iOS changes (#5881)
Browse files Browse the repository at this point in the history
* Update Gutenberg reference

* Update script for generating React-Codegen

The method we used to generate React-Codegen (get_react_codegen_spec) was moved to a different file in newer versions of React Native. We need to update the script for generating it accordingly.

* Update third-party podspecs to target 0.71.11

* Update FBReactNativeSpec.podspec.json with hash

* Apply bundle changes

* Manually add React-bridging.podspec.json

The file was automatically deleted via the generate-podspecs.sh script. It has been manually added as a temporary measure, to enable further testing.

* Revert "Manually add React-bridging.podspec.json"

This reverts commit 9707305.

* Update list of dependencies in Podfile for iOS

* Add tag to Hermes podspec to workaround error

This is intended as a temporary workaround, we should implement a more robust fix before merging.

* Update dependency versions in Podfile.lock

* [Temporary] Add React Native as a dependency

* Revert "[Temporary] Add React Native as a dependency"

This reverts commit 21a4fbe.

* Update Gutenberg ref

* Update Gutenberg ref

* Update Gutenberg ref

* Disable hermes when generating codegen podspec

* Generate third-party podspecs

* Update FBReactNativeSpec podspec

---------

Co-authored-by: Carlos Garcia <[email protected]>
  • Loading branch information
Siobhan Bamber and fluiddot authored Jul 4, 2023
1 parent 0713af5 commit 0b280a7
Show file tree
Hide file tree
Showing 53 changed files with 4,839 additions and 4,984 deletions.
29 changes: 19 additions & 10 deletions bin/generate-podspecs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,10 @@ RN_DIR="./"
SCRIPTS_PATH="./scripts/"
CODEGEN_REPO_PATH="../packages/react-native-codegen"
CODEGEN_NPM_PATH="../react-native-codegen"
PACKAGE_JSON_PATH="./package.json"
SRCS_DIR=${SRCS_DIR:-$(cd "./Libraries" && pwd)}
RN_VERSION=$(cat ./package.json | grep -m 1 version | sed 's/[^0-9.]//g')
HERMES_ENABLED="false"

RN_PODSPECS=$(find * -type f -name "*.podspec" -not -name "React-rncore.podspec" -not -path "third-party-podspecs/*" -not -path "*Fabric*" -print)
TMP_DEST=$(mktemp -d)
Expand Down Expand Up @@ -161,23 +163,30 @@ do
fi

# Generate React-Codegen
# A copy of react_native_pods is done to modify the content within get_react_codegen_spec
# A copy of codegen_utils.rb is done to modify the content within get_react_codegen_spec
# this enables getting the schema for React-Codegen in runtime by printing the content.
echo "Generating React-Codegen"
REACT_NATIVE_PODS_PATH="$SCRIPTS_PATH/react_native_pods.rb"
REACT_NATIVE_PODS_MODIFIED_PATH="$SCRIPTS_PATH/react_native_pods_modified.rb"
# Making a temp copy of react_native_pods.rb
cp $REACT_NATIVE_PODS_PATH $REACT_NATIVE_PODS_MODIFIED_PATH
REACT_NATIVE_CODEGEN_UTILS_PATH="$SCRIPTS_PATH/cocoapods/codegen_utils.rb"
REACT_NATIVE_CODEGEN_UTILS_MODIFIED_PATH="$SCRIPTS_PATH/cocoapods/codegen_utils_modified.rb"
# Making a temp copy of codegen_utils.rb
cp $REACT_NATIVE_CODEGEN_UTILS_PATH $REACT_NATIVE_CODEGEN_UTILS_MODIFIED_PATH
# Manually add the min_ios_version_supported variable to the CodegenUtils class
# The modified script won't be able to detect min_ios_version_supported otherwise
echo "
def min_ios_version_supported
'12.4'
end
" >> "$REACT_NATIVE_CODEGEN_UTILS_MODIFIED_PATH"
# Modify the get_react_codegen_spec method to return the result using print and JSON.pretty
sed -i '' -e "s/:git => ''/:git => 'https:\/\/github.com\/facebook\/react-native.git', :tag => 'v$RN_VERSION'/" "$REACT_NATIVE_PODS_MODIFIED_PATH"
sed -i '' -e 's/return spec/print JSON.pretty_generate(spec)/' "$REACT_NATIVE_PODS_MODIFIED_PATH"
sed -i '' -e "s/:git => ''/:git => 'https:\/\/github.com\/facebook\/react-native.git', :tag => 'v$RN_VERSION'/" "$REACT_NATIVE_CODEGEN_UTILS_MODIFIED_PATH"
sed -i '' -e 's/return spec/print JSON.pretty_generate(spec)/' "$REACT_NATIVE_CODEGEN_UTILS_MODIFIED_PATH"
# Run get_react_codegen_spec and generate React-Codegen.podspec.json
ruby -r "./scripts/react_native_pods_modified.rb" -e "get_react_codegen_spec" > "$DEST/React-Codegen.podspec.json"
ruby -r "./scripts/cocoapods/codegen_utils_modified.rb" -e "CodegenUtils.new.get_react_codegen_spec('$PACKAGE_JSON_PATH', hermes_enabled:$HERMES_ENABLED)" > "$DEST/React-Codegen.podspec.json"
TMP_ReactCodeGenSpec=$(mktemp)
jq '.source_files = "third-party-podspecs/FBReactNativeSpec/**/*.{c,h,m,mm,cpp}"' "$DEST/React-Codegen.podspec.json" > "$TMP_ReactCodeGenSpec"
mv "$TMP_ReactCodeGenSpec" "$DEST/React-Codegen.podspec.json"
# Remove temp copy of react_native_pods.rb
rm $REACT_NATIVE_PODS_MODIFIED_PATH
# Remove temp copy of codegen_utils.rb
rm $REACT_NATIVE_CODEGEN_UTILS_MODIFIED_PATH

echo "Generating schema from Flow types"
"$NODE_BINARY" "$CODEGEN_PATH/lib/cli/combine/combine-js-to-schema-cli.js" "$SCHEMA_FILE" "$SRCS_DIR"
Expand Down
7,980 changes: 4,022 additions & 3,958 deletions bundle/ios/App.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bundle/ios/App.js.map

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion ios-xcframework/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ DEPENDENCIES = %w[
RNCClipboard
RNFastImage
React-Codegen
React-bridging
React-jsc
React-hermes
].freeze

def gutenberg_dependencies
Expand Down
Loading

0 comments on commit 0b280a7

Please sign in to comment.