-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider relative to pwd installation root when looking for files in rn module via cocoapods #33399
Conversation
Base commit: bb8ff92 |
Base commit: bb8ff92 |
…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
Ping @dmitryrykun as he has relevant context on this. He already looked into relative path support for new arch so might be able to support here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great!
@dmitryrykun has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
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"; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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/scripts/react_native_pods.rb
Line 429 in 2a5265d
# react_native_path should be relative already. |
This pull request was successfully merged by @danilobuerger in 2f813f8. When will my fix make it into a release? | Upcoming Releases |
This pull request has been reverted by 06f504b. |
Hi @cortinico , @dmitryrykun 👋, any idea why this was reverted? |
Hi @danilobuerger , the PR itself is okay. I'm not sure what happened. I probably did something wrong during merge, and this PR landed in conjunction with other changes, that broke our internal CI. I'll investigate this tomorrow. Sorry for the confusion. |
… files in rn module via cocoapods (#33399) Summary: 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 ```bash bundle exec pod install --project-directory=ios ``` [iOS] [Fixed] - Fix usage of cocoapods with --project-directory flag and new arch Pull Request resolved: #33399 Test Plan: 1) Enable the new arch 2) Execute from the projects root dir ```bash bundle exec pod install --project-directory=ios ``` 3) It will fail with ``` [!] Invalid `Podfile` file: [codegen] Couldn't not find react-native-codegen.. ``` 4) Apply the patch 5) Execute from the projects root dir ```bash bundle exec pod install --project-directory=ios ``` 6) It will succeed
That was the reason essentially. It was reverted by another engineer. We can safely re-apply it now: #33427 |
…rn module via cocoapods (facebook#33399) Summary: 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 ```bash bundle exec pod install --project-directory=ios ``` ## Changelog [iOS] [Fixed] - Fix usage of cocoapods with --project-directory flag and new arch Pull Request resolved: facebook#33399 Test Plan: 1) Enable the new arch 2) Execute from the projects root dir ```bash bundle exec pod install --project-directory=ios ``` 3) It will fail with ``` [!] Invalid `Podfile` file: [codegen] Couldn't not find react-native-codegen.. ``` 4) Apply the patch 5) Execute from the projects root dir ```bash bundle exec pod install --project-directory=ios ``` 6) It will succeed Reviewed By: ShikaSD Differential Revision: D34784966 Pulled By: dmitryrykun fbshipit-source-id: d6d5e71bc2fcd32f2cd60a498f39e6f772fc9005
Summary
The
:reactNativePath
provided byuse_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 likebundle exec pod install --project-directory=ios
Changelog
[iOS] [Fixed] - Fix usage of cocoapods with --project-directory flag and new arch
Test Plan
bundle exec pod install --project-directory=ios
bundle exec pod install --project-directory=ios