-
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
Fix compatibility with CocoaPods frameworks #25393
Conversation
…rrors in several podspecs
…th React/ imports
I can see there are some failures due to the changed imports. I will update them shortly. Update: Done now in 7ab5c34. I feel like there may be a better solution though. |
Hey James! Thanks for opening the PR 🙇♂️ It looks quite the big PR - even if the changes are few per file - so we'll try to get some extra people to take a close look. |
#import <RCTAnimation/RCTAnimationUtils.h> | ||
#else | ||
#import <RCTAnimation/RCTAnimationUtils.h> | ||
#endif |
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.
This should use React/RCTAnimationUtils.h
I think?
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.
You're right and I just pushed as you commented this 😄 Thanks!
@@ -47,7 +47,7 @@ Pod::Spec.new do |spec| | |||
source_files = File.join('ReactCommon/yoga', source_files) if ENV['INSTALL_YOGA_WITHOUT_PATH_OPTION'] | |||
spec.source_files = source_files | |||
|
|||
header_files = 'yoga/{Yoga,YGEnums,YGMacros,YGValue,YGStyle,CompactValue,YGFloatOptional,Yoga-internal,YGNode,YGConfig,YGLayout,YGMarker}.h' | |||
header_files = 'yoga/{Yoga,YGEnums,YGMacros,YGValue}.h' |
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.
What's going on with this change?
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.
Ah, found the discussion at the top
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.
This reverts a change that was made in #23803 which admittedly I don't have full context on.
The reason it is needed is that with all of the headers public, the module fails to build when imported into RCTImageSource.m
with the error below because the headers include C++ code.
▸ Compiling RCTImageSource.m
❌ /Users/james/src/tmp/AwesomeProject/node_modules/react-native/ReactCommon/yoga/yoga/CompactValue.h:11:10: 'cmath' file not found
#include <cmath>
^~~~~~~~~~~~~~~~~~~~~~~~~
❌ /Users/james/src/tmp/AwesomeProject/node_modules/react-native/React/Base/RCTConvert.h:17:9: could not build module 'yoga'
#import <yoga/Yoga.h>
^~~~~~~
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.
Cool, I think the fundamentals here are good.
Any chance you could give an example of what someone would have had to have been doing to see this?
This may be a breaking change if these are imported externally
( One advantage is that this setup for Podspecs only came out in 0.60 (I think? dang, this has been a long release )
Thanks, @orta!
Sure. As a result of this change any user code that imports the non-core modules would need to be updated. For example, if someone is using |
@ericlewis Eric, any thoughts? |
Just a quick note about the breaking change mentioned above. The timing is probably reasonable since there are other breaking changes in 0.60.0. Although I still think its the best thing to do, its worth pointing out an alternative. We could add a
Its a little hacky, but it would allow all existing imports to continue to work. |
@kelset I just saw your comment about releasing the latest RC. I totally understand the core team have so many other things to do. However, given that this PR proses breaking changes, it would be really great if it could be included in 0.60.0. Let me know if there is anything I can do to help make this happen. |
Hey James - yes, I fully agree with you. And I'd love to see it in 0.60.0 but it seems that internally FB has been working on things that would be touched by this PR, and they want to see those land before this... which means more delays for 0.60.0. I'll try to raise it once more but honestly can't promise anything, it's not something I have full control over 😓 |
@kelset That's completely fair. Thanks for the update and all your help! |
Hey @jtreanor, this PR was mostly blocked on some work I've been doing on RNTesterPods to ensure we can run these tests on our internal CI. I asked folks to hold off on touching RNTesterPods to avoid some nasty conflicts when we landed this internally. As it happens, we had to revert the change due to an issue related to what you're fixing on this PR, so let's just go ahead and get this merged. I'll rebase my changes on top of this. Thanks for fixing this! |
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.
@hramos is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
I should also say that, in my opinion, these changes meet the bar for a 0.60-RC cherry-pick as they fix an issue introduced in 0.60 itself. My upcoming changes mostly focus on moving the iOS tests from RNTester to RNTesterPods, so we should not block 0.60 on getting my own RNTesterPods changes in. |
Question: is the issue here header namespace collisions across podspecs? I think in the ideal world we'd like most namespace header to be just This PR will require a lot of changes in various BUCK files we have today (to fix the namespace), and unfortunately they are not mapped 1-to-1 (in dir structure) with .podspecs yet (fixable, but requires bunch of refactoring unrelated to this PR). So I think it'll take some time to land this PR. We're looking into it. |
My biggest concern is wether or not well badly break 3rd party libs. Do we have an assessment on what that could cause? From reading the issue about headers, it’ll take time to propagate, but libs will be actively updating too. This may result in major version changes across many libs and it should be considered. How prepared are we to do that, and is there an easy upgrade path for the libs that dont have the resources to move as quickly as the rest of us. |
And to add to @fkgozali this in my opinion would probably break all of OSS fabric & I’m not exactly sure how to fix it. The library is extremely reliant on very specific naming structure. But it’s also not an accidental feature. This forces scary constraints and seemingly a divide. |
Thanks for your input @fkgozali and @ericlewis.
Yes, that is exactly the issue. Since RN is now split across several podspecs, Xcode builds them each as a separate framework and the headers live separately in each. With
This is a very valid point and I don't have a good answer for the scale of impact on third party libs. As it stands, any header imported from As I mentioned above, there may be a hacky solution to merging all the headers into one namespace, but its not ideal. There may be another way to achieve this and I'm very open to suggestions. Its worth clarifying that this PR fixes importing RN from Swift files. As it stands on master,
Can you clarify what you mean by this? I'm not very familiar with Fabric but as far as I can tell, everything in the repo still builds fine as I have updated the required imports. |
I looked into the actual issue today to understand the problem better: Problem 1: Colliding .framework names
Given that we have a lot of For the rest of the .podspec's, I think we'll have to adapt the new namespace (e.g. like what Fabric did). This could be breaking change, but I'm hoping it's minimized since it's not the React-Core lib. Problem 2: Incomplete Dependencies in the podspecSome of our .podspecs are missing direct dependencies. E.g. Problem 3: Something broke this in v0.60Based on #25349, it seems like something broke this in v0.60. I'm not sure which commits caused it, but it would be best for 0.60 dot release (?) to revert the offending commits. @jtreanor do you know? Then, we can fix things forward in master. [1] https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPFrameworks/Tasks/IncludingFrameworks.html |
Btw, it looks like we hit the same problem back in the day: CocoaPods/CocoaPods#4605 (comment) And the suggested workaround for now is to add HEADER_SEARCH_PATH, e.g. https://github.com/facebook/react-native/pull/12089/files#diff-66230b3e029caa37b0fbdc8cbd47f4abR50 |
Thanks for taking a look at this @fkgozali. What you have summarised here matches my understanding of the situation.
Yeah. Although this might be possible, I haven't found a way to do this. Even if it was, I'm not sure it would be a good idea.
This is what I have done in this PR. If we fully commit to the new namespacing, a few updates will need to be made to
That's a good point. I can make a new PR that makes these changes. There are also a few instances of missing
Both Problem 1 and Problem 2 here were introduced by I don't think reverting the podspec split is a viable option here.
Thanks for sharing! I don't think |
cc'ing in @fson since he was the author of the split |
As suggested above, I have opened a new PR with the non-breaking changes from this one in #25496. These should address the issues in "Problem 2" mentioned in #25393 (comment). Proposal for avoiding colliding .framework namesAs for "Problem 1", I have come up with a way that we could make these changes without breaking any of the exiting
I have tested this and it works. Here what it would look like for
|
@jtreanor Thanks for the proposal. I think it will be worth trying it out. A few things we can clean up:
|
Great, thanks @fkgozali. I will go ahead with trying this approach. I should be able to get to it in the next day or two. |
Summary: This is the first step towards fixing #25349. These are the changes to the podspec to correctly update dependencies and build config that will cause any breaking change for users or libraries. I am breaking these changes out from #25393 as suggested by fkgozali in #25393 (comment). These are the changes: - Made C++ headers in `React-Core` private by default so that ObjC files can import the module without failures. - Reduced the number of `yoga` headers that are exposed for the same reason as above. As far as I can see this doesn't cause issues but we can find another solution if it does. - Adding some missing dependencies to fix undefined symbols errors. - Added `DoubleConversion` to `HEADER_SEARCH_PATHS` where it was missing. ## Changelog [iOS] [Fixed] - Updated podspecs for improved compatibility with different install types. Pull Request resolved: #25496 Test Plan: Everything should work exactly as before. I have a branch on my [sample project](https://github.com/jtreanor/react-native-cocoapods-frameworks) here which points at this branch to show that it is still working `Podfile` to demonstrate this is fixed. You can see that it works with these steps: 1. `git clone git@github.com:jtreanor/react-native-cocoapods-frameworks.git` 2. `git checkout podspec-updates` 3. `cd ios && pod install` 4. `cd .. && react-native run-ios` The sample app will build and run successfully. Reviewed By: mmmulani Differential Revision: D16167346 Pulled By: fkgozali fbshipit-source-id: 1917b2f8779cb172362a457fb3fce686c55056d3
Okay, I have put together a draft PR for the subspec solution in #25619. It was quite a bit more involved than I anticipated and there is still some work to do. I'm keen to get some feedback before spending any more time on it. It doesn't avoid all breaking changes but |
Summary: For better compatibility re: #25393, this target should just use `RCTTypeSafety` Reviewed By: PeteTheHeat Differential Revision: D16210888 fbshipit-source-id: 6a55d631453cc420909247a7d5a64379587225b7
Summary: For better cocoapods compatibility, refactored TM podspec to be a subspec of ReactCommon, then use `<ReactCommon/` header prefix for all TM files. Relevant efforts: #25619 #25393 Reviewed By: hramos Differential Revision: D16231697 fbshipit-source-id: 38d3418b19978ff54aa0c61b064ac45ac0e1c36c
Nice job! |
Closing in favour of #25619. |
Summary: This is my proposal for fixing `use_frameworks!` compatibility without breaking all `<React/*>` imports I outlined in #25393 (comment). If accepted, it will fix #25349. It builds on the changes I made in #25496 by ensuring each podspec has a unique value for `header_dir` so that framework imports do not conflict. Every podspec which should be included in the `<React/*>` namespace now includes it's headers from `React-Core.podspec`. The following pods can still be imported with `<React/*>` and so should not have breaking changes: `React-ART`,`React-DevSupport`, `React-CoreModules`, `React-RCTActionSheet`, `React-RCTAnimation`, `React-RCTBlob`, `React-RCTImage`, `React-RCTLinking`, `React-RCTNetwork`, `React-RCTPushNotification`, `React-RCTSettings`, `React-RCTText`, `React-RCTSettings`, `React-RCTVibration`, `React-RCTWebSocket` . There are still a few breaking changes which I hope will be acceptable: - `React-Core.podspec` has been moved to the root of the project. Any `Podfile` that references it will need to update the path. - ~~`React-turbomodule-core`'s headers now live under `<turbomodule/*>`~~ Replaced by #25619 (comment). - ~~`React-turbomodulesamples`'s headers now live under `<turbomodulesamples/*>`~~ Replaced by #25619 (comment). - ~~`React-TypeSaferty`'s headers now live under `<TypeSafety/*>`~~ Replaced by #25619 (comment). - ~~`React-jscallinvoker`'s headers now live under `<jscallinvoker/*>`~~ Replaced by #25619 (comment). - Each podspec now uses `s.static_framework = true`. This means that a minimum of CocoaPods 1.5 ([released in April 2018](http://blog.cocoapods.org/CocoaPods-1.5.0/)) is now required. This is needed so that the ` __has_include` conditions can still work when frameworks are enabled. Still to do: - ~~Including `React-turbomodule-core` with `use_frameworks!` enabled causes the C++ import failures we saw in #25349. I'm sure it will be possible to fix this but I need to dig deeper (perhaps a custom modulemap would be needed).~~ Addressed by 3357351. - I haven't got Fabric working yet. I wonder if it would be acceptable to move Fabric out of the `<React/*>` namespace since it is new? � ## Changelog [iOS] [Fixed] - Fixed compatibility with CocoaPods frameworks. Pull Request resolved: #25619 Test Plan: ### FB ``` buck build catalyst ``` ### Sample Project Everything should work exactly as before, where `use_frameworks!` is not in `Podfile`s. I have a branch on my [sample project](https://github.com/jtreanor/react-native-cocoapods-frameworks) here which has `use_frameworks!` in its `Podfile` to demonstrate this is fixed. You can see that it works with these steps: 1. `git clone git@github.com:jtreanor/react-native-cocoapods-frameworks.git` 2. `git checkout fix-frameworks-subspecs` 3. `cd ios && pod install` 4. `cd .. && react-native run-ios` The sample app will build and run successfully. To see that it still works without frameworks, remove `use_frameworks!` from the `Podfile` and do steps 3 and 4 again. ### RNTesterPods `RNTesterPodsPods` can now work with or without `use_frameworks!`. 1. Go to the `RNTester` directory and run `pod install`. 2. Run the tests in `RNTesterPods.xcworkspace` to see that everything still works fine. 3. Uncomment the `use_frameworks!` line at the top of `RNTester/Podfile` and run `pod install` again. 4. Run the tests again and see that it still works with frameworks enabled. Reviewed By: PeteTheHeat Differential Revision: D16465247 Pulled By: PeteTheHeat fbshipit-source-id: cad837e9cced06d30cc5b372af1c65c7780b9e7a
Summary: This is the first step towards fixing facebook#25349. These are the changes to the podspec to correctly update dependencies and build config that will cause any breaking change for users or libraries. I am breaking these changes out from facebook#25393 as suggested by fkgozali in facebook#25393 (comment). These are the changes: - Made C++ headers in `React-Core` private by default so that ObjC files can import the module without failures. - Reduced the number of `yoga` headers that are exposed for the same reason as above. As far as I can see this doesn't cause issues but we can find another solution if it does. - Adding some missing dependencies to fix undefined symbols errors. - Added `DoubleConversion` to `HEADER_SEARCH_PATHS` where it was missing. [iOS] [Fixed] - Updated podspecs for improved compatibility with different install types. Pull Request resolved: facebook#25496 Test Plan: Everything should work exactly as before. I have a branch on my [sample project](https://github.com/jtreanor/react-native-cocoapods-frameworks) here which points at this branch to show that it is still working `Podfile` to demonstrate this is fixed. You can see that it works with these steps: 1. `git clone git@github.com:jtreanor/react-native-cocoapods-frameworks.git` 2. `git checkout podspec-updates` 3. `cd ios && pod install` 4. `cd .. && react-native run-ios` The sample app will build and run successfully. Reviewed By: mmmulani Differential Revision: D16167346 Pulled By: fkgozali fbshipit-source-id: 1917b2f8779cb172362a457fb3fce686c55056d3
Summary: This is my proposal for fixing `use_frameworks!` compatibility without breaking all `<React/*>` imports I outlined in facebook#25393 (comment). If accepted, it will fix facebook#25349. It builds on the changes I made in facebook#25496 by ensuring each podspec has a unique value for `header_dir` so that framework imports do not conflict. Every podspec which should be included in the `<React/*>` namespace now includes it's headers from `React-Core.podspec`. The following pods can still be imported with `<React/*>` and so should not have breaking changes: `React-ART`,`React-DevSupport`, `React-CoreModules`, `React-RCTActionSheet`, `React-RCTAnimation`, `React-RCTBlob`, `React-RCTImage`, `React-RCTLinking`, `React-RCTNetwork`, `React-RCTPushNotification`, `React-RCTSettings`, `React-RCTText`, `React-RCTSettings`, `React-RCTVibration`, `React-RCTWebSocket` . There are still a few breaking changes which I hope will be acceptable: - `React-Core.podspec` has been moved to the root of the project. Any `Podfile` that references it will need to update the path. - ~~`React-turbomodule-core`'s headers now live under `<turbomodule/*>`~~ Replaced by facebook#25619 (comment). - ~~`React-turbomodulesamples`'s headers now live under `<turbomodulesamples/*>`~~ Replaced by facebook#25619 (comment). - ~~`React-TypeSaferty`'s headers now live under `<TypeSafety/*>`~~ Replaced by facebook#25619 (comment). - ~~`React-jscallinvoker`'s headers now live under `<jscallinvoker/*>`~~ Replaced by facebook#25619 (comment). - Each podspec now uses `s.static_framework = true`. This means that a minimum of CocoaPods 1.5 ([released in April 2018](http://blog.cocoapods.org/CocoaPods-1.5.0/)) is now required. This is needed so that the ` __has_include` conditions can still work when frameworks are enabled. Still to do: - ~~Including `React-turbomodule-core` with `use_frameworks!` enabled causes the C++ import failures we saw in facebook#25349. I'm sure it will be possible to fix this but I need to dig deeper (perhaps a custom modulemap would be needed).~~ Addressed by facebook@3357351. - I haven't got Fabric working yet. I wonder if it would be acceptable to move Fabric out of the `<React/*>` namespace since it is new? � [iOS] [Fixed] - Fixed compatibility with CocoaPods frameworks. Pull Request resolved: facebook#25619 Test Plan: ``` buck build catalyst ``` Everything should work exactly as before, where `use_frameworks!` is not in `Podfile`s. I have a branch on my [sample project](https://github.com/jtreanor/react-native-cocoapods-frameworks) here which has `use_frameworks!` in its `Podfile` to demonstrate this is fixed. You can see that it works with these steps: 1. `git clone git@github.com:jtreanor/react-native-cocoapods-frameworks.git` 2. `git checkout fix-frameworks-subspecs` 3. `cd ios && pod install` 4. `cd .. && react-native run-ios` The sample app will build and run successfully. To see that it still works without frameworks, remove `use_frameworks!` from the `Podfile` and do steps 3 and 4 again. `RNTesterPodsPods` can now work with or without `use_frameworks!`. 1. Go to the `RNTester` directory and run `pod install`. 2. Run the tests in `RNTesterPods.xcworkspace` to see that everything still works fine. 3. Uncomment the `use_frameworks!` line at the top of `RNTester/Podfile` and run `pod install` again. 4. Run the tests again and see that it still works with frameworks enabled. Reviewed By: PeteTheHeat Differential Revision: D16465247 Pulled By: PeteTheHeat fbshipit-source-id: cad837e9cced06d30cc5b372af1c65c7780b9e7a
Summary: This is the first step towards fixing facebook/react-native#25349. These are the changes to the podspec to correctly update dependencies and build config that will cause any breaking change for users or libraries. I am breaking these changes out from facebook/react-native#25393 as suggested by fkgozali in facebook/react-native#25393 (comment). These are the changes: - Made C++ headers in `React-Core` private by default so that ObjC files can import the module without failures. - Reduced the number of `yoga` headers that are exposed for the same reason as above. As far as I can see this doesn't cause issues but we can find another solution if it does. - Adding some missing dependencies to fix undefined symbols errors. - Added `DoubleConversion` to `HEADER_SEARCH_PATHS` where it was missing. [iOS] [Fixed] - Updated podspecs for improved compatibility with different install types. Pull Request resolved: facebook/react-native#25496 Test Plan: Everything should work exactly as before. I have a branch on my [sample project](https://github.com/jtreanor/react-native-cocoapods-frameworks) here which points at this branch to show that it is still working `Podfile` to demonstrate this is fixed. You can see that it works with these steps: 1. `git clone git@github.com:jtreanor/react-native-cocoapods-frameworks.git` 2. `git checkout podspec-updates` 3. `cd ios && pod install` 4. `cd .. && react-native run-ios` The sample app will build and run successfully. Reviewed By: mmmulani Differential Revision: D16167346 Pulled By: fkgozali fbshipit-source-id: 1917b2f8779cb172362a457fb3fce686c55056d3
Summary: This is the first step towards fixing facebook/react-native#25349. These are the changes to the podspec to correctly update dependencies and build config that will cause any breaking change for users or libraries. I am breaking these changes out from facebook/react-native#25393 as suggested by fkgozali in facebook/react-native#25393 (comment). These are the changes: - Made C++ headers in `React-Core` private by default so that ObjC files can import the module without failures. - Reduced the number of `yoga` headers that are exposed for the same reason as above. As far as I can see this doesn't cause issues but we can find another solution if it does. - Adding some missing dependencies to fix undefined symbols errors. - Added `DoubleConversion` to `HEADER_SEARCH_PATHS` where it was missing. [iOS] [Fixed] - Updated podspecs for improved compatibility with different install types. Pull Request resolved: facebook/react-native#25496 Test Plan: Everything should work exactly as before. I have a branch on my [sample project](https://github.com/jtreanor/react-native-cocoapods-frameworks) here which points at this branch to show that it is still working `Podfile` to demonstrate this is fixed. You can see that it works with these steps: 1. `git clone git@github.com:jtreanor/react-native-cocoapods-frameworks.git` 2. `git checkout podspec-updates` 3. `cd ios && pod install` 4. `cd .. && react-native run-ios` The sample app will build and run successfully. Reviewed By: mmmulani Differential Revision: D16167346 Pulled By: fkgozali fbshipit-source-id: 1917b2f8779cb172362a457fb3fce686c55056d3
Summary
This fixes #25349. It allows React and the related pods to be integrated into
Podfile
s that useuse_frameworks!
. Some more background is explained in the issue.The fix involves a number of changes:
s.header_dir
to avoid conflicts with#import <React/X>
imports. This may be a breaking change if these are imported externally.React-Core
private by default so that ObjC files can import the module without failures.yoga
headers that are exposed for the same reason as above. As far as I can see this doesn't cause issues but we can find another solution if it does.DoubleConversion
toHEADER_SEARCH_PATHS
where it was missing.Note: The
React-RCTFabric
andReact-Fabric
pods are still incompatible withuse_frameworks!
, but work fine without it. Some more updates will be needed there.Changelog
[iOS] [Fixed] - Fixed compatibility with CocoaPods frameworks.
Test Plan
Everything should work exactly as before, where
use_frameworks!
is not inPodfile
s. I have a branch on my sample project here which hasuse_frameworks!
in itsPodfile
to demonstrate this is fixed.You can see that it works with these steps:
git clone git@github.com:jtreanor/react-native-cocoapods-frameworks.git
git checkout fix-frameworks
cd ios && pod install
cd .. && react-native run-ios
The sample app will build and run successfully. To see that it still works without frameworks, remove
use_frameworks!
from thePodfile
and do steps 3 and 4 again.