Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 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";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @danilobuerger! Is react_native_path guaranteed to be relative? Does this work if it is absolute?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dmitryrykun guaranteed might be a bit too strong 😅 But currently its always returned as a relative path from use_native_modules!. See https://github.com/react-native-community/cli/blob/master/packages/platform-ios/native_modules.rb#L124

Also the rest of the code assumes its relative too: For example

# react_native_path should be relative already.

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 Expand Up @@ -509,6 +510,7 @@ def use_react_native_codegen_discovery!(options={})
app_path = options[:app_path]
fabric_enabled = options[:fabric_enabled] ||= false
config_file_dir = options[:config_file_dir] ||= ''
relative_installation_root = Pod::Config.instance.installation_root.relative_path_from(Pathname.pwd)

if !app_path
Pod::UI.warn '[Codegen] Error: app_path is required for use_react_native_codegen_discovery.'
Expand All @@ -524,7 +526,7 @@ def use_react_native_codegen_discovery!(options={})
out = Pod::Executable.execute_command(
'node',
[
"#{react_native_path}/scripts/generate-artifacts.js",
"#{relative_installation_root}/#{react_native_path}/scripts/generate-artifacts.js",
"-p", "#{app_path}",
"-o", Pod::Config.instance.installation_root,
"-e", "#{fabric_enabled}",
Expand Down
4 changes: 2 additions & 2 deletions template/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ target 'HelloWorld' do
# to enable hermes on iOS, change `false` to `true` and then install pods
:hermes_enabled => flags[:hermes_enabled],
:fabric_enabled => flags[:fabric_enabled],
# An abosolute path to your application root.
:app_path => "#{Dir.pwd}/.."
# An absolute path to your application root.
:app_path => "#{Pod::Config.instance.installation_root}/.."
)

target 'HelloWorldTests' do
Expand Down