-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
rename yoga podspec to ReactYoga to prevent clash with YogaKit #20758
Conversation
While following my test plan, I found out that the import statements for yoga are now different for when using CocoaPods. I assumed that since a 1 possible solution is renaming Another solution would be that RN is going to use the official Yoga source, but then implementing projects have to use the same version of Yoga, which possibly will be lagging behind. |
I've added a commit that updates all the imports for yoga to be conditional, which in my testing works with all possible configurations; I've also created an example app that demonstrates the use of YogaKit in conjunction with React Native: https://github.com/koenpunt/ReactYogaExample |
It's bit of a breaking change - existing consumers may need to change However, I think the idea is in the right place. This doc will also need an update. 👍 |
Worth noting that these changes would likely stay this way in a post- react-native-community/discussions-and-proposals#18 world too. |
@orta thanks for chiming in! Would really see this change happen, because currently I'm rolling with patched version of RN. Also nice to see your proposal regarding RN and CocoaPods 👍 |
And I've already submitted a PR for the documentation change for when this gets merged, hopefully, eventually: facebook/react-native-website#521 |
i don't see these modifications in master branch. so who can tell me the bug is already fixed? |
What's the status of this PR? |
I'll bring it up-to-date with master somewhere in the coming hours |
@koenpunt are you planning on doing the update? |
@cpojer technically, this should be fine, internally this podspec is separate from Yoga’s. Not sure what the best way for apps with multiple deps on Yoga really is, though. Can this cause linker problems? |
@davidaurelio ah, that makes sense, thank you. In that case I think we should go ahead and merge this PR once @koenpunt rebases. |
cc @fson |
I've rebased once more and squashed the commits into one. |
Since now all podspecs have been split up with names like |
Yeah, I think so, good idea |
Should be good now. I've also removed the |
Adding `YogaKit` to a brownfield React Native project caused a name clash, because `Yoga`, a dependency of `YogaKit` did install in the same folder as the `yoga` library that comes with React Native, which made it impossible to use `YogaKit` in an React Native app. By renaming the bundled yoga podspec they no longer install in the same directory.
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.
Let's ship it.
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.
@cpojer is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
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.
@koenpunt We’d very much like to not have this include switch in YGJNI.cpp
, and Yoga’s code base as a whole.
- Yoga is used by different OSS projects. I would rather not set a precedent to special-case one of them.
- Other projects using Yoga want to continue to work with compilers that don’t implement
__has_include(…)
- There is no test that would stop Yoga contributors from removing that if/else.
Can we isolate the solution to the cocoapods level? I am not sure whether this is going to work, but what about:
- organising the React-yoga pod such that it has an extra
yoga/
subdirectory - use
spec.header_search_paths
(example) in React Native’s pod file(s). - continue to use
#include <yoga/…>
everywhere.
Speaking of having two versions of Yoga in a project: how does that work in the end when everything is linked?
I wasn't aware this was an imported library, I assumed they are all local sources.
From my experience this wasn't a problem. But in the end it would of course be better if RN would just use the published version of yoga, instead of the bundled one. Not sure why this wasn't possible, but I believe it has to do with the fact that Facebook doesn't use cocoapods, so there are different releases used internally than those that are published to cocoapods. |
Sorry about that – it isn’t really obvious that internally we just mirror Yoga into RN, even though they go to different repositories.
The internal setup might not be the problem. Maybe the RN team would like to have an extra copy to be able to make changes without releasing new versions. That would be another valid way of doing things. Is there any chance that my suggestion is going to work out? That seems to be a way to clean up without introducing too many changes at once. |
I think it would be best to avoid using the When not using the header search path hack, I believe the |
👋 - took a look at this again, I'm a little confused about how two copies of Yoga can ever co-exist in the app? Native code shouldn't allow for two versions of the same library without some pretty hectic code changes. Is it possible that instead we could loosen the YogaKit Podspec dependency to allow either the React version, or a version that is shipped directly from their repo? |
It seems like we are unlikely to move forward with this PR so I'm going to close it. @koenpunt if you are still interested in resolving this issue, please check out the latest comments by @davidaurelio @fson and @orta and send a new PR. Thank you! |
Summary
Adding
YogaKit
to a brownfield React Native project caused a name clash, becauseYoga
, a dependency ofYogaKit
did install in the same folder as theyoga
library that comes with React Native, which made it impossible to useYogaKit
in an React Native app.By renaming the bundled yoga podspec they no longer install in the same directory.
I might be unaware of other ways of preventing this name clash on a project level, but I figured this would be the most robust solution for everybody.
Fixes #20651
Test Plan:
This is change that affects the build process, so if the build still succeeds it should still work, but additionally I will build and run the RNTester app and see if that still works. And for the cocoapods implementation I will create a sample app that integrates React Native and YogaKit, and will verify that it still works.
Release Notes:
[IOS] [Fixed] - Prevent name clash with YogaKit and Yoga