Skip to content

Conversation

@p-mazhnik
Copy link
Contributor

@p-mazhnik p-mazhnik commented Jun 28, 2023

A lot of details are written in the feature request: #114692.

tl;dr: Options B & C from the add2app iOS guide have a limitation (build error) in case the Flutter plugin and native iOS app have a shared dependency. We can use a workaround to avoid the issue, but in this case we don't need to build frameworks for plugins.

Closes #114692
Part of #130220

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@p-mazhnik p-mazhnik changed the title [flutter_tool] build ios-frameworks: option to exclude plugin frameworks from the build [flutter_tools] build ios-frameworks: option to exclude plugin frameworks from the build Jun 28, 2023
@p-mazhnik p-mazhnik force-pushed the ios-frameworks-no-plugins branch from 876467d to c74bf10 Compare June 28, 2023 19:54
@p-mazhnik p-mazhnik force-pushed the ios-frameworks-no-plugins branch from 59f0075 to 95d4343 Compare June 30, 2023 14:54
@github-actions github-actions bot added c: contributor-productivity Team-specific productivity, code health, technical debt. tool Affects the "flutter" command-line tool. See also t: labels. labels Jun 30, 2023
@christopherfujino christopherfujino added the platform-ios iOS applications specifically label Jul 6, 2023
@stuartmorgan-g
Copy link
Contributor

Am I understanding correctly that the only benefit here is reducing build times?

If so, in isolation it's not clear to me that this is worth the complexity of adding and supporting. The flag seems rather difficult to use correctly, and it seems like the benefit of having it is minimal, so it seems like adding it as a supported output mode is something of a foot-gun.

@hyiso
Copy link
Contributor

hyiso commented Aug 19, 2023

We also need this.

Currently we have one Flutter module used in two iOS App, it has a number of plugins which transitively depend on many of native iOS Pods.

We build this module twice with some difference in --dart-define passed to flutter build ios-framework.

During each build process, the Building plugins step takes about 20 minutes because there are so many Pods being compiled, so the whole build process (running flutter build ios-framework twice) takes about 1 hour every time.

But we only need a new App.xcframework at the second build, so a flag like --no-plugins will reduce the build time a lot.

@hyiso
Copy link
Contributor

hyiso commented Aug 19, 2023

@stuartmorgan Please reconsider this, reducing build time is something important when build time is a annoying problem.

IMO, it is sad to ignore a helpful feature only for avoiding people use it wrong

@zhyky
Copy link

zhyky commented Aug 22, 2023

Similar problem, we are also facing the build time cost problem.

@christopherfujino
Copy link
Contributor

Per discussion on discord, this is on @stuartmorgan TODO list.

@arthurmonteiroalvesmelo

We need this too.

@eliasyishak
Copy link
Contributor

@stuartmorgan friendly ping

1 similar comment
@christopherfujino
Copy link
Contributor

@stuartmorgan friendly ping

..addFlag('plugins',
defaultsTo: true,
help: 'Whether to produce frameworks for the plugins. '
'Consider using "--no-plugins" if plugin frameworks are not required.',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This second sentence doesn't seem to be adding anything; it's just saying to consider using the flag if you want the behavior of the flag. (It also sounds like people should pass it if they have no plugins, which isn't necessary or useful.)

I think this should instead discuss how this would need to be used. E.g., "This is intended for cases where plugins are already being built separately."

help: 'Whether to produce frameworks for the plugins. '
'Consider using "--no-plugins" if plugin frameworks are not required.',
)
..addFlag('static',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passing both --static and --no-plugins should be an error, since that would be a mistake, and it's not clear what someone would expect it to do.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this to validations

globals.printStatus('Frameworks written to ${outputDirectory.path}.');

if (!project.isModule && hasPlugins(project)) {
if (!project.isModule && boolArg('plugins') && hasPlugins(project)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this being gated on the plugins flag? This step should be basically free (so wouldn't impact build times, which as I understand it is the driver for this PR), and it's not at all clear to me that it wouldn't be needed in the use cases described here. Isn't the intended outcome that the app still has and uses plugins, they are just built separately? Building all the plugins via some other mechanism doesn't remove the need for a registrant.

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. To @jmagman for a second review.

await _testBuildFrameworksWithoutPlugins(projectDir, platform: 'macos');

section('check --static cannot be used with the --no-plugins flag');
await _testStaticAndNoPlugins(projectDir);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is testing ios-frameworks only but you put it in the macOS test section. I can't remember if we allow the static flag for macOS (if we do I suspect it doesn't do anything?) I know these files are huge and a mess. 😞

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! _testStaticAndNoPlugins function run build ios-framework internally, that is why tests pass. --static is not supported for macos.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 5, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 5, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 5, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 6, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 6, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 6, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 6, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 6, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 6, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 7, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 7, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 7, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 7, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 7, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 7, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 8, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 8, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 8, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 8, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 8, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 8, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 8, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 8, 2023
@p-mazhnik p-mazhnik deleted the ios-frameworks-no-plugins branch December 11, 2023 16:08
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 16, 2024
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 c: contributor-productivity Team-specific productivity, code health, technical debt. platform-ios iOS applications specifically tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Add2App] provide flag for 'build ios-framework' command to build only App.xcframework

8 participants