Skip to content

Commit

Permalink
Fix the generation of .xcode.env.local (#46661)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #46661

The previous approach was brittle and it was not working in all the scenarios.

This is the same approach used [by Expo](https://github.com/expo/expo/blob/12f24ea7fdbc8bab864d7852ae8e7275e44db4df/packages/expo-modules-autolinking/scripts/ios/xcode_env_generator.rb#L37C44-L37C75) (thanks guys! :D) and it looks like it is more stable.

This should definitely fix [#43285](#43285).

## Changelog
[Internal] - Fix the generation of .xcode.env.local

Reviewed By: cortinico

Differential Revision: D63460707

fbshipit-source-id: c6732adce3df5f8365b17ed9c500c38f773ecee5
  • Loading branch information
cipolleschi authored and facebook-github-bot committed Sep 30, 2024
1 parent 4e38493 commit aa35a21
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions packages/react-native/scripts/cocoapods/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -236,16 +236,9 @@ def self.create_xcode_env_if_missing(file_manager: File)
if !file_manager.exist?("#{file_path}.local")
# When installing pods with a yarn alias, yarn creates a fake yarn and node executables
# in a temporary folder.
# Using `type -a` we are able to retrieve all the paths of an executable and we can
# exclude the temporary ones.
# Using `node --print "process.argv[0]";` we are able to retrieve the actual path from which node is running.
# see https://github.com/facebook/react-native/issues/43285 for more info
node_binary = `type -a node`.split("\n").map { |path|
path.gsub!("node is ", "")
}.select { |b|
!b.start_with?("/var")
}

node_binary = node_binary[0]
node_binary = `node --print "process.argv[0]";`
system("echo 'export NODE_BINARY=#{node_binary}' > #{file_path}.local")
end
end
Expand Down

0 comments on commit aa35a21

Please sign in to comment.