From 041365eb299d4600ba0b4eef70e42a280885a91c Mon Sep 17 00:00:00 2001 From: Craig Martin Date: Thu, 6 May 2021 11:18:35 -0700 Subject: [PATCH] fix: codegen - project paths with spaces (#31141) Summary: - Fixed iOS codegen script incorrectly splitting root project paths that contain spaces https://github.com/react-native-community/releases/issues/214#issuecomment-793089063 iOS builds were failing on 0.64.0-rc.4 for projects that contained spaces in the root directory path. The error logs pointed to the codegen script not being able to find a directory. The path was being split at a space in one of the folder names. This PR modifies the codegen script to include the spaces and use the entire project root path. ## Changelog [Internal] fix: codegen script failing for iOS builds on projects with spaces in root directory path Pull Request resolved: https://github.com/facebook/react-native/pull/31141 Test Plan: Failing Test: Upgrade or init a new project and make sure that the project root directory contains a space (ex: /Users/test/cool projects/app/). With a clean install of node_modules and pods, attempt to build the project with Xcode. The build fails with an error running the script in FBReactNativeSpec (no such file or directory). Passing Test: Include the changes presented in this PR and rerun the failing test (clean node_modules + PR patch/clean pods). The app should build. Reviewed By: mdvacca Differential Revision: D28255539 Pulled By: hramos fbshipit-source-id: d44011985750639bd2fabfd40ed645d4eb661bd7 --- scripts/react_native_pods.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/react_native_pods.rb b/scripts/react_native_pods.rb index 602b7bf1de6..7c8b623ea6a 100644 --- a/scripts/react_native_pods.rb +++ b/scripts/react_native_pods.rb @@ -163,9 +163,9 @@ def use_react_native_codegen!(spec, options={}) modules_output_dir = "React/#{modules_library_name}/#{modules_library_name}" # Run the codegen as part of the Xcode build pipeline. - env_vars = "SRCS_DIR=#{js_srcs}" - env_vars += " MODULES_OUTPUT_DIR=#{prefix}/#{modules_output_dir}" - env_vars += " MODULES_LIBRARY_NAME=#{modules_library_name}" + env_vars = "SRCS_DIR='#{js_srcs}'" + env_vars += " MODULES_OUTPUT_DIR='#{prefix}/#{modules_output_dir}'" + env_vars += " MODULES_LIBRARY_NAME='#{modules_library_name}'" generated_dirs = [ modules_output_dir ] generated_filenames = [ "#{modules_library_name}.h", "#{modules_library_name}-generated.mm" ] @@ -176,7 +176,7 @@ def use_react_native_codegen!(spec, options={}) # Eventually, we want these to be part of the same library as #{modules_library_name} above. components_output_dir = "ReactCommon/react/renderer/components/rncore/" generated_dirs.push components_output_dir - env_vars += " COMPONENTS_OUTPUT_DIR=#{prefix}/#{components_output_dir}" + env_vars += " COMPONENTS_OUTPUT_DIR='#{prefix}/#{components_output_dir}'" components_generated_filenames = [ "ComponentDescriptors.h", "EventEmitters.cpp", @@ -198,5 +198,5 @@ def use_react_native_codegen!(spec, options={}) :execution_position => :before_compile, :show_env_vars_in_log => true } - spec.prepare_command = "mkdir -p #{generated_dirs.reduce("") { |str, dir| "#{str} ../../#{dir}" }} && touch #{generated_files.reduce("") { |str, filename| "#{str} ../../#{filename}" }}" + spec.prepare_command = "mkdir -p #{generated_dirs.map {|dir| "'../../#{dir}'"}.join(" ")} && touch #{generated_files.map {|file| "'../../#{file}'"}.join(" ")}" end