Skip to content

Conversation

@intspt
Copy link
Contributor

@intspt intspt commented Apr 27, 2023

image
image
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.

@flutter-dashboard flutter-dashboard bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Apr 27, 2023
@google-cla
Copy link

google-cla bot commented Apr 27, 2023

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.

@intspt intspt force-pushed the feature/transitive_dependency branch from 85759a7 to 46132cc Compare April 27, 2023 07:13
@intspt intspt marked this pull request as ready for review April 27, 2023 07:20
@luckysmg luckysmg requested a review from jmagman April 28, 2023 03:40
@jmagman
Copy link
Member

jmagman commented Apr 28, 2023

@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.

@intspt
Copy link
Contributor Author

intspt commented May 4, 2023

@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
The dependency tree is the same in the normal_demo and bug_demo scenarios.

NativePod -> shared_preferences -> Flutter

In 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.
image

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.
image

@jmagman
Copy link
Member

jmagman commented May 4, 2023

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
https://github.com/flutter/flutter/blob/c2022aa5b140544e103025e6995b41c872e39d2c/dev/devicelab/lib/tasks/plugin_tests.dart or https://github.com/flutter/flutter/blob/master/dev/devicelab/bin/tasks/build_ios_framework_module_test.dart for an example of where that could live.

@intspt
Copy link
Contributor Author

intspt commented May 6, 2023

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 https://github.com/flutter/flutter/blob/c2022aa5b140544e103025e6995b41c872e39d2c/dev/devicelab/lib/tasks/plugin_tests.dart or https://github.com/flutter/flutter/blob/master/dev/devicelab/bin/tasks/build_ios_framework_module_test.dart for an example of where that could live.

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.
We put Flutter.framework, App.framework, and framework compiled by plugin into a pod called IdlefishFlutter. The purpose is to allow several scenarios such as local development of Flutter projects, local development of native parts, and remote packaging to be used normally.
Therefore, in these scenarios, native pods can only rely on IdlefishFlutter.
image

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.

@intspt
Copy link
Contributor Author

intspt commented May 6, 2023

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 https://github.com/flutter/flutter/blob/c2022aa5b140544e103025e6995b41c872e39d2c/dev/devicelab/lib/tasks/plugin_tests.dart or https://github.com/flutter/flutter/blob/master/dev/devicelab/bin/tasks/build_ios_framework_module_test.dart for an example of where that could live.

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.

@stuartmorgan-g
Copy link
Contributor

stuartmorgan-g commented May 6, 2023

@intspt as request above:

Can you file an actual GitHub issue instead of updating this PR

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

This problem was encountered in our own project, and there should be no similar issues.

Almost all problems are encountered in developers' projects. That doesn't mean that nobody can ever encounter the same issue.

@intspt
Copy link
Contributor Author

intspt commented May 8, 2023

@intspt as request above:

Can you file an actual GitHub issue instead of updating this PR

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

This problem was encountered in our own project, and there should be no similar issues.

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.

@hyiso
Copy link
Contributor

hyiso commented May 18, 2023

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

@intspt
Copy link
Contributor Author

intspt commented May 18, 2023

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

Recursive operations increase the time consumption very little. Taking our project as an example, there are about 320+ pods. The total time of flutter_additional_ios_build_settings is about 1s.
now:
image
before:
image

@christopherfujino
Copy link
Contributor

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.

@christopherfujino christopherfujino marked this pull request as draft June 8, 2023 21:34
@stuartmorgan-g stuartmorgan-g marked this pull request as ready for review July 25, 2023 20:16
@stuartmorgan-g
Copy link
Contributor

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.

@stuartmorgan-g
Copy link
Contributor

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

@hyiso Are you saying you saw actual performance problems with this PR applied? What does your dependency graph look like?

Copy link
Contributor

@stuartmorgan-g stuartmorgan-g left a 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.

@hyiso
Copy link
Contributor

hyiso commented Jul 26, 2023

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

@hyiso Are you saying you saw actual performance problems with this PR applied? What does your dependency graph look like?

Yes, after applying this PR, it stuck at Generating Pods project over 10 minutes when running pod install.

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 next unless target.dependencies.any? { |dependency| dependency.name == 'Flutter' } in this file

@hyiso
Copy link
Contributor

hyiso commented Jul 26, 2023

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

@hyiso Are you saying you saw actual performance problems with this PR applied? What does your dependency graph look like?

Yes, after applying this PR, it stuck at Generating Pods project over 10 minutes when running pod install.

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 next unless target.dependencies.any? { |dependency| dependency.name == 'Flutter' } in this file

As mentioned here #125610 (comment), after adding return false, the stuck disappeared.

I'll continue to try this PR to check whether the problem <Flutter/Flutter.h> not found is solved

@hyiso
Copy link
Contributor

hyiso commented Jul 30, 2023

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

@hyiso Are you saying you saw actual performance problems with this PR applied? What does your dependency graph look like?

Yes, after applying this PR, it stuck at Generating Pods project over 10 minutes when running pod install.
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 next unless target.dependencies.any? { |dependency| dependency.name == 'Flutter' } in this file

As mentioned here #125610 (comment), after adding return false, the stuck disappeared.

I'll continue to try this PR to check whether the problem <Flutter/Flutter.h> not found is solved

Seems not solved in my host iOS project, I'll keep to use my workaround.

@christopherfujino
Copy link
Contributor

@intspt are you still interested in working on this?

@christopherfujino christopherfujino added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Sep 7, 2023
@intspt
Copy link
Contributor Author

intspt commented Sep 8, 2023

@intspt are you still interested in working on this?

I'm sorry for not seeing the previous reply, I'm still interested.
I will modify my code as soon as possible as per stuartmorgan's suggestion.

Copy link
Contributor

@stuartmorgan-g stuartmorgan-g left a 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.)

Copy link
Contributor

@vashworth vashworth left a 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

@intspt
Copy link
Contributor Author

intspt commented Sep 21, 2023

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.

@intspt
Copy link
Contributor Author

intspt commented Oct 23, 2023

@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.

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.

@stuartmorgan-g
Copy link
Contributor

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?

@intspt
Copy link
Contributor Author

intspt commented Oct 23, 2023

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?

Copy link
Member

@jmagman jmagman left a 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

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!

@jmagman
Copy link
Member

jmagman commented Jan 3, 2024

@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.

@vashworth
Copy link
Contributor

@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

@intspt
Copy link
Contributor Author

intspt commented Jan 12, 2024

@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

@intspt intspt requested a review from vashworth January 13, 2024 09:29
Copy link
Contributor

@vashworth vashworth left a 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!

@vashworth vashworth added the autosubmit Merge PR when tree becomes green via auto submit App label Jan 16, 2024
@auto-submit auto-submit bot merged commit 3d11242 into flutter:master Jan 16, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 17, 2024
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Jan 17, 2024
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App tool Affects the "flutter" command-line tool. See also t: labels. waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds

Projects

None yet

Development

Successfully merging this pull request may close these issues.

<Flutter/Flutter.h> cannot be imported when a pod transitive depends on Flutter

6 participants