Skip to content

Commit

Permalink
Set REACT_NATIVE_NODE_MODULES_DIR env var before fetching Reanimate…
Browse files Browse the repository at this point in the history
…d pod
  • Loading branch information
fluiddot committed Jul 5, 2023
1 parent 3bbb8b7 commit 630b737
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions ios-xcframework/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,18 @@ def gutenberg_dependencies

computed_dependencies.delete('React-jsc') unless HERMES_ENABLED

# Use a custom RNReanimated version while we coordinate a fix upstream
computed_dependencies.each do |pod_name|
pod pod_name, podspec: "#{podspec_prefix}/third-party-podspecs/#{pod_name}.podspec.json"
end

pod 'RNReanimated', git: 'https://github.com/wordpress-mobile/react-native-reanimated', branch: 'mokagio/fix-custom-node_modules-bypass-multiple-versions-check-2.17.0'
# This is required to workaround an issue with RNReanimated after upgrading to version 2.17.0
rn_node_modules = File.join(Dir.pwd, '..', 'gutenberg', 'node_modules')
raise "Could not find node modules at given path #{rn_node_modules}" unless File.exist? rn_node_modules
ENV['REACT_NATIVE_NODE_MODULES_DIR'] = rn_node_modules
puts "[Gutenberg] Set REACT_NATIVE_NODE_MODULES_DIR env var for RNReanimated to #{rn_node_modules}"

# Use a custom RNReanimated version while we coordinate a fix upstream
pod 'RNReanimated', git: 'https://github.com/wordpress-mobile/react-native-reanimated', branch: 'wp-fork-2.17.0'
end

VERSION_XCCONFIG_PATH = File.join(File.expand_path(__dir__), 'Config', 'Gutenberg-Shared.xcconfig')
Expand All @@ -74,17 +80,6 @@ target 'Gutenberg' do
gutenberg_dependencies
end

pre_install do
# This is required to workaround an issue with RNReanimated after upgrading to version 2.17.0
rn_node_modules = File.join(Dir.pwd, '..', 'gutenberg', 'node_modules')

raise "Could not find node modules at given path #{rn_node_modules}" unless File.exist? rn_node_modules

ENV['REACT_NATIVE_NODE_MODULES_DIR'] = rn_node_modules

puts "[Gutenberg] Set REACT_NATIVE_NODE_MODULES_DIR env var for RNReanimated to #{rn_node_modules}"
end

post_install do |installer|
react_native_post_install(installer, REACT_NATIVE_PATH)

Expand Down

3 comments on commit 630b737

@mokagio
Copy link
Contributor

@mokagio mokagio commented on 630b737 Jul 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fluiddot @dcalhoun thank you for implementing this, while I hadn't run in the issue myself, I can see who moving the value here might make the setup more robust.

I originally used the pre_install hook because it seemed more attuned to my interpretation of "the CocoaPods way™" , but if this works, I'm all in for it.

This approach definitely ensures the env var is set before any operation related to that pod runs, which should guarantee it to be available to the pod in all scenarios.

@fluiddot
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I originally used the pre_install hook because it seemed more attuned to my interpretation of "the CocoaPods way™" , but if this works, I'm all in for it.

I checked the documentation of the pre_install hook and says:

This hook allows you to make any changes to the Pods after they have been downloaded but before they are installed.

My impression was that setting the env var in pre_install was the optimal approach, but seems some configuration in the Reanimated pod is happening before the installation process. That's why I went with the option for setting the env var directly before the pod is defined. However, if we find a better approach that guarantees that REACT_NATIVE_NODE_MODULES_DIR is set before processing the pod, I'm also in for it.

@mokagio
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but seems some configuration in the Reanimated pod is happening before the installation process.

I think that's the case, too, although I haven't dug into it. It wouldn't surprise me if there were additional steps CocoaPods makes in between downloading and installing.

👌

Please sign in to comment.