-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Solve the problem that <Flutter/Flutter.h> cannot be imported when a pod transitive depends on Flutter #125610
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
Solve the problem that <Flutter/Flutter.h> cannot be imported when a pod transitive depends on Flutter #125610
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
85759a7 to
46132cc
Compare
|
@intspt can you file an issue that describes exactly what you're seeing and how to reproduce it? I don't understand how you got into the state from those screenshots. |
I have provided a demo to reproduce this problem: https://github.com/intspt/bug_demo NativePod -> shared_preferences -> FlutterIn the normal_demo, cocoapods added the directory of Flutter.framework to the FRAMEWORK_SEARCH_PATHS of NativePod. Because shared_preferences dependencies will be inherited to NativePod. But in the bug_demo, Flutter is a fake pod. FRAMEWORK_SEARCH_PATHS is processed by podhelper, which misses the scenarios of transitive dependencies, so an error will be reported during compilation. |
|
Can you file an actual GitHub issue instead of updating this PR? I am not quite sure the use case of a native pod depending on a Flutter plugin, for example, and it's better to have that conversation documented in an issue since that's generally where folks will look for duplicates, etc. Additionally, this will need a test. Unfortunately we don't really have Ruby tests so it would need to be an integration test, see |
Our app is called Xianyu. This problem was encountered in our own project, and there should be no similar issues. The most direct solution to this problem is to make the native pod depend on Flutter. But we can't do this in our project. Of course, the root cause of this problem is that there are some flaws in the processing of podhelper. I think it is a reasonable solution to keep the processing logic of podhelper consistent with the logic of cocoapods. |
This change is only to add the directory where Flutter.framework is located in the FRAMEWORK_SEARCH_PATHS of the pod that transitive depends on Flutter. This problem may only be encountered in the Add-to-app scenario. So it seems impossible to add this scenario in the integration test. |
|
@intspt as request above:
We have a standard process, which includes separating discussion of what the problem is (the issue tracker) and reviewing a fix (PR discussion). Following our process will make things go more smoothly
Almost all problems are encountered in developers' projects. That doesn't mean that nobody can ever encounter the same issue. |
I raised an issue, #126251. |
|
Tried this PR, this might cause a long time waiting at 'Generating Pods project' when running pod install. Maybe the recursive depth should be limited |
|
I'm going to mark this PR as a draft for now, as it seems per the discussion on #126251 it is not clear if the issue is one that should be fixed in the Flutter SDK. I think we should resolve that in that issue first, before reviewing this PR. |
|
Apologies for the delay in getting back to this; looking further at the use case, this seems like a reasonable solution. For non-add-to-app cases it seems like this should have minimal impact. |
@hyiso Are you saying you saw actual performance problems with this PR applied? What does your dependency graph look like? |
stuartmorgan-g
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.
As mentioned above, this will need an automated test.
Yes, after applying this PR, it stuck at The host iOS project has a lot of pod dependencies (I don't know how to count the total number). But I'm not sure whether it is a bug of the PR or just related to the dependencies complication, as @intspt said he does not have this problem. BTW, my current workaround is just to comment out this line |
As mentioned here #125610 (comment), after adding I'll continue to try this PR to check whether the problem |
Seems not solved in my host iOS project, I'll keep to use my workaround. |
|
@intspt are you still interested in working on this? |
I'm sorry for not seeing the previous reply, I'm still interested. |
stuartmorgan-g
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.
LGTM. @vashworth, could you do the secondary review?
(Also, it looks like this will need to be synced with main to resolve CI issues.)
vashworth
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.
LGTM, but as @stuartmorgan and @jmagman previously requested, this will need an integration test. See previous comment (#125610 (comment)) for some examples
ok, I'll add an integration test for this change. But I have been busy recently, so I will be able to provide it later. |
Hello, I don’t know how to write this integration test task. I need to create a native pod that depends on any Flutter Plugin, but it doesn't seem possible. |
Why wouldn't that be possible; isn't that exactly the case that this PR is intended to handle? |
But I don’t know how to introduce the pod I want in the integration test. Can I write the contents of the podspec and .m file into the dart file? |
jmagman
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.
Sorry for the long delay on this PR, it shouldn't have been left for this long.
Additionally, this will need a test.
Okay I looked into this more and oh man would this be tricky to test. Probably in this code
flutter/dev/devicelab/lib/tasks/plugin_tests.dart
Lines 74 to 80 in c2022aa
| final _FlutterProject app = await _FlutterProject.create(tempDir, options, buildTarget, | |
| name: 'plugintestapp', template: 'app', environment: appCreateEnvironment); | |
| try { | |
| section('Add plugins'); | |
| await app.addPlugin('plugintest', | |
| pluginPath: path.join('..', 'plugintest')); | |
| await app.addPlugin('path_provider'); |
we would need to add a
NativePod.podspec that depends on plugintest but not Flutter, but does @import Flutter. Then change the plugintestapp/ios/Podfile to pod 'NativePod', :path => right/path/here in the right spot.
Or create a new project in https://github.com/flutter/flutter/tree/master/dev/integration_tests that has this all set up, which is quite a lot of code to test something so obscure that I would say isn't even correct behavior--if you import Flutter you should declare it as a dependency.
However I really don't want to be overly pedantic for such a harmless change (more than I already have been 🙂 ). Famous last words I guess. I'm going to approve this and you'll probably be responsible someday for noticing if the behavior broke, and filing a bug, and fixing it.
Apologies again for this hanging out so long, and for this being really tough to test. We appreciate your contribution!
|
@vashworth if you want to hold the testing line here I totally understand since you still have this marked as changes requested. We should either approve it or close it (or write the test ourselves) since it's been hanging out so long. |
|
@intspt Here's how I would add it to the plugin_test_ios integration test. Feel free to use this code in this PR: master...vashworth:flutter:flutter_transitive_dependency_test |
thx, I'll finish it this weekend |
vashworth
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.
LGTM. Thanks for adding tests!
… when a pod transitive depends on Flutter (flutter/flutter#125610)
flutter/flutter@8e94423...def6af0 2024-01-17 [email protected] Roll Flutter Engine from 73a2de5da53f to c7e328518bc0 (5 revisions) (flutter/flutter#141673) 2024-01-17 [email protected] Manual roll Flutter Engine from 1382ff79dd6d to 73a2de5da53f (2 revisions) (flutter/flutter#141667) 2024-01-17 [email protected] Roll Flutter Engine from d4b6b7ec8e48 to 1382ff79dd6d (7 revisions) (flutter/flutter#141664) 2024-01-17 [email protected] TrainHoppingAnimation should dispatch creation and disposal events. (flutter/flutter#141635) 2024-01-17 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Roll Flutter Engine from d4b6b7ec8e48 to 021a5ff5eae6 (5 revisions)" (flutter/flutter#141659) 2024-01-17 [email protected] [flutter_tools] Fix analyze size on arm64 (flutter/flutter#141317) 2024-01-17 [email protected] Roll Flutter Engine from d4b6b7ec8e48 to 021a5ff5eae6 (5 revisions) (flutter/flutter#141651) 2024-01-16 [email protected] Update TESTOWNERS iskakaushik -> dnfield (flutter/flutter#141649) 2024-01-16 [email protected] Allow selection in composing region (flutter/flutter#140516) 2024-01-16 [email protected] Roll Flutter Engine from eab7bd3b0999 to d4b6b7ec8e48 (1 revision) (flutter/flutter#141643) 2024-01-16 [email protected] Roll Flutter Engine from f20657354d8b to eab7bd3b0999 (12 revisions) (flutter/flutter#141638) 2024-01-16 [email protected] Fixed few typos (flutter/flutter#141543) 2024-01-16 [email protected] Add contexts to mac_ios targets. (flutter/flutter#141494) 2024-01-16 [email protected] handle rc versions of gradle in version compare (flutter/flutter#141612) 2024-01-16 [email protected] Delete redundant `settings.ext.flutterSdkPath` (flutter/flutter#141509) 2024-01-16 [email protected] Roll Packages from d21f3b8 to 7dd0fcb (2 revisions) (flutter/flutter#141630) 2024-01-16 [email protected] Reference GitHub issue in TODO comment (flutter/flutter#141582) 2024-01-16 [email protected] migrate {min,target,compile}SdkVersion to {min,target,compile}Sdk (flutter/flutter#141537) 2024-01-16 [email protected] Sort Swift imports in templates (flutter/flutter#141487) 2024-01-16 [email protected] Ignore or fix leaks. (flutter/flutter#141468) 2024-01-16 [email protected] Solve the problem that <Flutter/Flutter.h> cannot be imported when a pod transitive depends on Flutter (flutter/flutter#125610) 2024-01-16 [email protected] Fix #141061: Add 'color' property to `DrawerButton` and `EndDrawerButton` (flutter/flutter#141159) 2024-01-15 [email protected] Roll Packages from d74d687 to d21f3b8 (5 revisions) (flutter/flutter#141573) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md





If a pod transitive depends on a pod containing a framework, cocoapods will add the path of the framework to its FRAMEWORK_SEARCH_PATHS.
So I modified the relevant logic in podhelper, hoping to be consistent with the behavior of cocoapods.
Fixes #126251.