Skip to content

Commit aa35a21

Browse files
cipolleschifacebook-github-bot
authored andcommitted
Fix the generation of .xcode.env.local (#46661)
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
1 parent 4e38493 commit aa35a21

File tree

1 file changed

+2
-9
lines changed
  • packages/react-native/scripts/cocoapods

1 file changed

+2
-9
lines changed

packages/react-native/scripts/cocoapods/utils.rb

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -236,16 +236,9 @@ def self.create_xcode_env_if_missing(file_manager: File)
236236
if !file_manager.exist?("#{file_path}.local")
237237
# When installing pods with a yarn alias, yarn creates a fake yarn and node executables
238238
# in a temporary folder.
239-
# Using `type -a` we are able to retrieve all the paths of an executable and we can
240-
# exclude the temporary ones.
239+
# Using `node --print "process.argv[0]";` we are able to retrieve the actual path from which node is running.
241240
# see https://github.com/facebook/react-native/issues/43285 for more info
242-
node_binary = `type -a node`.split("\n").map { |path|
243-
path.gsub!("node is ", "")
244-
}.select { |b|
245-
!b.start_with?("/var")
246-
}
247-
248-
node_binary = node_binary[0]
241+
node_binary = `node --print "process.argv[0]";`
249242
system("echo 'export NODE_BINARY=#{node_binary}' > #{file_path}.local")
250243
end
251244
end

0 commit comments

Comments
 (0)