From 1b22e8a039081887ffd450596d822bff975d6900 Mon Sep 17 00:00:00 2001 From: Tommy Nguyen <4123478+tido64@users.noreply.github.com> Date: Thu, 12 May 2022 16:26:38 +0200 Subject: [PATCH] Fix `pod install --project-directory=ios` failing when Hermes is enabled --- scripts/react_native_pods.rb | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/scripts/react_native_pods.rb b/scripts/react_native_pods.rb index d95ff4ab625936..7f2defeea57a15 100644 --- a/scripts/react_native_pods.rb +++ b/scripts/react_native_pods.rb @@ -666,11 +666,14 @@ def use_react_native_codegen!(spec, options={}) def downloadAndConfigureHermesSource(react_native_path) hermes_tarball_base_url = "https://github.com/facebook/hermes/tarball/" - sdks_dir = "#{react_native_path}/sdks" - download_dir = "#{sdks_dir}/download" - hermes_dir = "#{sdks_dir}/hermes" - hermes_tag_file = "#{sdks_dir}/.hermesversion" - system("mkdir -p #{hermes_dir} #{download_dir}") + + sdks_dir = Pod::Config.instance.installation_root.join(react_native_path, "sdks") + download_dir = sdks_dir.join("download") + hermes_dir = sdks_dir.join("hermes") + hermes_tag_file = sdks_dir.join(".hermesversion") + + hermes_dir.mkpath + download_dir.mkpath if (File.exist?(hermes_tag_file)) hermes_tag = File.read(hermes_tag_file).strip @@ -680,19 +683,19 @@ def downloadAndConfigureHermesSource(react_native_path) hermes_tarball_url = hermes_tarball_base_url + hermes_tag hermes_tag_sha = %x[git ls-remote https://github.com/facebook/hermes #{hermes_tag} | cut -f 1].strip - hermes_tarball_path = "#{download_dir}/hermes-#{hermes_tag_sha}.tar.gz" + hermes_tarball_path = download_dir.join("hermes-#{hermes_tag_sha}.tar.gz") if (!File.exist?(hermes_tarball_path)) Pod::UI.puts "[Hermes] Downloading Hermes source code..." - system("curl #{hermes_tarball_url} -Lo #{hermes_tarball_path}") + system("curl #{hermes_tarball_url} -Lo #{hermes_tarball_path.to_s}") end Pod::UI.puts "[Hermes] Extracting Hermes tarball (#{hermes_tag_sha.slice(0,6)})" - system("tar -zxf #{hermes_tarball_path} --strip-components=1 --directory #{hermes_dir}") + system("tar -zxf #{hermes_tarball_path.to_s} --strip-components=1 --directory #{hermes_dir.to_s}") # TODO: Integrate this temporary hermes-engine.podspec into the actual one located in facebook/hermes - system("cp #{sdks_dir}/hermes-engine.podspec #{hermes_dir}/hermes-engine.podspec") + FileUtils.cp(sdks_dir.join("hermes-engine.podspec"), hermes_dir.join("hermes-engine.podspec")) - hermes_dir + hermes_dir.relative_path_from(Pod::Config.instance.installation_root).to_s end # This provides a post_install workaround for build issues related Xcode 12.5 and Apple Silicon (M1) machines.