-
Notifications
You must be signed in to change notification settings - Fork 25k
fix(iOS): pod install fails outside ios folder
#30469
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
Conversation
|
LGTM 👍 |
alloy
left a comment
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.
Nice 👌
| # Path to React Native relative to where `pod install` was invoked. This can | ||
| # sometimes be inside the `ios` folder (i.e. `pod install `), or outside | ||
| # (e.g. `pod install --project_directory=ios`). | ||
| prefix = options[:path] ||= resolve_module "react-native" |
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.
To keep it the same with use_react_native, we should probably just stick to options[:path] and pass it like here:
react-native/template/ios/Podfile
Lines 7 to 9 in 355239b
| config = use_native_modules! | |
| use_react_native!(:path => config[:reactNativePath]) |
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.
reactNativePath can be programatically set in the react-native.config.js and might be not what this resolves to in use_react_native!.
Example: https://github.com/facebook/react-native/blob/master/react-native.config.js#L32
Set to . for React Native root, this will not work inside React Native repository as there's no module to require.resolve to.
This can lead to some unexpected issues.
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.
Looks like codegen_pre_install(:path => config[:reactNativePath]) present in a default template would resolve all issues without any further code changes.
The reason is: when we tell codegen_pre_install to use config[:reactNativePath] as I said above, which is an absolute path to React Native location, then, path to codegen would always be correct, since it's going to be absolute too.
("#{prefix}/../react-native-codegen" out of prefix which 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.
Technically, the assumption of react-native-codegen living side by side react-native can be false in the following scenario:
node_modules/react-native-codegen (0.0.7)
packageA/node_modules/react-native (0.64.0-rc.0)
packageB/node_modules/react-native (0.64.0-rc.1)
In other words, two React Native packages sharing same React Native codegen version.
In that case, it may be worth to leave resolve_module just for react-native-codegen or... we make sure that react-native-codegen is always versioned together with the React Native (same version as the RC, with patch bump).
This is the idea going forward, but at the time of writing, the aforementioned scenario is technically possible.
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.
Not quite sure I understand what you mean here… The root of this issue is that we cannot use the same path for both use_react_native! and codegen_pre_install. use_react_native! needs paths that are relative to the Podfile because CocoaPods will be resolving modules later. codegen_pre_install, on the other hand, needs the paths to be relative to the current working directory because it is invoked right away.
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.
Sorry, didn't see your replies until after I had posted this. The scenario you mentioned in the last post is a very real one for us. I'd rather leave it like this.
grabbou
left a comment
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.
Requested changes in a comment - I believe we should stick to reactNativePath like in use_react_native! to keep it synchronised. Then, we don't need to resolve anything.
|
I am also trying to understand why did we introduce another script, Why don't we just make it part of https://github.com/facebook/react-native/blob/master/template/ios/Podfile#L16 CC: @alloy |
|
@grabbou It’s a good question, but think that's moot at this point, as the intent is to move invocation of the codegen compiler out of the Podfile entirely as it needs to be part of the build pipeline: #30449 I.e. I don’t think there needs to be too much work done here, as it will likely be removed soon anyways. |
@alloy: If codegen is going to be moved out of Podfile, wouldn't it make sense to do that now before we ship 0.64? Are we telling consumers to add this function, then remove it in the next version? |
|
It makes sense to update the Podfile with a path tho, as a part of making it easier for users to play around with the RC. |
Maybe then we should have this PR point directly to the 0.64 branch instead on master? That way we can roll it back once we have the proper codegen fix? |
Yeah I think this makes sense 👍 |
|
Note to self: Don't change the base branch on GitHub before rebasing the branch. |
355239b to
8d5ef5b
Compare
|
alloy
left a comment
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.
The remaining CI failures appear to be because of the missing shelljs dependency that @grabbou should already have a PR for.
|
I am happy with partially accepting it as it will go away anyway. But... as I mentioned in my comment here, I would prefer we do not |
I don't mind either way as this will be move out of Podfile but as you also mentioned in #30469 (comment), hoisting is an issue and it does affect us. Using the same |
|
It looks like #30449 will be in the next RC, but if that doesn’t end up happening I think we can pull in this change for the time being. I don’t feel knowledgeable enough about the monorepo aspect of path handling and wether or not that should hold this up for that short period. |
|
Superseded by #30449. |
Summary
Invoking
pod installoutside theiosfolder fails becausecodegen_pre_install()looks fornode_modulesin the parent folder.Changelog
[iOS] [Fixed] -
pod install --project-directory=iosfails to findreact-native-codegenTest Plan
Both
pod install(insideiosfolder) andpod install --project-directory=ios(outsideiosfolder) should work.