Skip to content

Commit

Permalink
Consider relative to pwd installation root when looking for files in …
Browse files Browse the repository at this point in the history
…rn module via cocoapods

The :reactNativePath provided by use_native_modules! is the rn module path relative to the installation root (usually ./ios). However, when executing cocoapods from a dir thats not the installation root, packages that use the relative :reactNativePath variable in their path must also consider the relative to pwd installation root.

This fixes usage of cocoapods with the --project-directory flag like

bundle exec pod install --project-directory=ios
  • Loading branch information
danilobuerger committed Mar 9, 2022
1 parent bb8ff92 commit 0d5b72a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions scripts/react_native_pods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,9 @@ def modify_flags_for_new_architecture(installer, cpp_flags)
end

def build_codegen!(react_native_path)
codegen_repo_path = "#{react_native_path}/packages/react-native-codegen";
codegen_npm_path = "#{react_native_path}/../react-native-codegen";
relative_installation_root = Pod::Config.instance.installation_root.relative_path_from(Pathname.pwd)
codegen_repo_path = "#{relative_installation_root}/#{react_native_path}/packages/react-native-codegen";
codegen_npm_path = "#{relative_installation_root}/#{react_native_path}/../react-native-codegen";
codegen_cli_path = ""
if Dir.exist?(codegen_repo_path)
codegen_cli_path = codegen_repo_path
Expand Down Expand Up @@ -319,7 +320,7 @@ def checkAndGenerateEmptyThirdPartyProvider!(react_native_path)
Pod::Executable.execute_command(
'node',
[
"#{react_native_path}/scripts/generate-provider-cli.js",
"#{relative_installation_root}/#{react_native_path}/scripts/generate-provider-cli.js",
"--platform", 'ios',
"--schemaListPath", temp_schema_list_path,
"--outputDir", "#{output_dir}"
Expand Down

0 comments on commit 0d5b72a

Please sign in to comment.