Skip to content

[tool] Migrate Apple build subcommands and toolchain to modular dependency injection - #190780

Merged
auto-submit[bot] merged 22 commits into
flutter:masterfrom
bkonyi:di/15-apple-build-and-toolchain
Sep 4, 2026
Merged

auto-submit[bot] merged 22 commits into
flutter:masterfrom
bkonyi:di/15-apple-build-and-toolchain

Conversation

@bkonyi

@bkonyi bkonyi commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Part 15 of the modular dependency injection migration.

  • Migrates Apple build subcommands to modular constructor dependency injection:
    • BuildIOSCommand({required super.appleContext, required super.buildSystem, required super.toolContext, required super.verboseHelp})
    • BuildIOSFrameworkCommand({required super.appleContext, required super.buildSystem, required super.toolContext, required super.verboseHelp})
    • BuildMacOSCommand({required BuildSystem buildSystem, required ToolContext toolContext, required bool verboseHelp})
    • BuildMacOSFrameworkCommand({required super.appleContext, required super.buildSystem, required super.toolContext, required super.verboseHelp})
  • Uses object destructuring to extract context members (appleContext, toolContext) and eliminates ambient globals.
  • Adds fake_build_command.dart test helper and adds Terminal support to FakeToolContext.
  • Converts unit tests across test/commands.shard/hermetic/build_ios_test.dart, build_macos_test.dart, and build_darwin_framework_test.dart to hermetic testWithoutContext.

Part of #188471

@github-actions github-actions Bot added tool Affects the "flutter" command-line tool. See also t: labels. team-android Owned by Android platform team team-ios Owned by iOS platform team team-macos Owned by the macOS platform team labels Aug 8, 2026
@bkonyi
bkonyi force-pushed the di/15-apple-build-and-toolchain branch 6 times, most recently from ce6f1c4 to 06645da Compare August 12, 2026 18:39
@bkonyi
bkonyi force-pushed the di/15-apple-build-and-toolchain branch from 06645da to 7f04e0b Compare September 2, 2026 13:25
@bkonyi
bkonyi marked this pull request as ready for review September 2, 2026 13:25
@bkonyi bkonyi added the CICD Run CI/CD label Sep 2, 2026
@bkonyi
bkonyi requested review from a team as code owners September 2, 2026 13:25
@github-actions github-actions Bot removed the team-android Owned by Android platform team label Sep 2, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request refactors BuildCommand and its subcommands to use constructor dependency injection for dependencies like ToolContext and AppleContext instead of relying on global variables. The corresponding unit tests are updated to use helper functions for instantiating these commands with mock contexts. Feedback on the changes includes a potential regression in BuildIOSCommand where reading the device ID directly from globalResults bypasses the FLUTTER_DEVICE_ID environment variable, an inconsistency in BuildCommand where the passed platform parameter is not used uniformly, and instances where the terminal variable is typed as the concrete AnsiTerminal instead of the generic Terminal interface.

Comment thread packages/flutter_tools/lib/src/commands/build_ios.dart Outdated
Comment thread packages/flutter_tools/lib/src/commands/build.dart Outdated
Comment thread packages/flutter_tools/lib/src/commands/build_ios.dart Outdated
Comment thread packages/flutter_tools/lib/src/commands/build_ios.dart Outdated
@bkonyi

bkonyi commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the BuildCommand and its subcommands in flutter_tools to use a new ToolContext and AppleContext for dependency injection, replacing the previous global-based access pattern. It also updates several test files to support these changes by introducing helper functions for command creation. The review feedback identifies missing imports in test files that are necessary to resolve compilation errors for the newly introduced Fake classes.

Comment thread packages/flutter_tools/test/commands.shard/hermetic/build_ios_test.dart Outdated
@bkonyi

bkonyi commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request refactors various build commands, including BuildCommand, BuildIOSCommand, and BuildMacOSFrameworkCommand, to accept dependency-injected contexts (AppleContext, ToolContext, and BuildSystem) instead of relying on global variables, which improves testability. Corresponding unit tests are updated to utilize helper methods for instantiating these commands with fake contexts. Feedback on the changes suggests refactoring the constructor of BuildCommand to eliminate redundant instantiations of CocoaPods and Xcode when setting up the effective AppleContext.

Comment thread packages/flutter_tools/lib/src/commands/build.dart Outdated
@bkonyi

bkonyi commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request refactors BuildCommand and its subcommands (including BuildIOSCommand, BuildIOSFrameworkCommand, BuildMacosCommand, and BuildMacOSFrameworkCommand) to use dependency injection via ToolContext and AppleContext instead of relying on global variables. Unit tests are updated to use helper instantiation methods. Feedback on these changes suggests simplifying the BuildCommand constructor by moving the inline dependency graph construction to a factory, and warns against using the PersistentToolState.test() constructor in production code paths.

Comment thread packages/flutter_tools/lib/src/commands/build.dart Outdated
Comment thread packages/flutter_tools/lib/src/commands/build.dart Outdated
@bkonyi

bkonyi commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request refactors several build commands in flutter_tools to accept injected contexts (AppleContext, ToolContext, and BuildSystem) instead of relying on global variables, improving testability. The corresponding unit tests have been updated to use helper methods for command instantiation. Feedback includes using effectivePlatform instead of platform when instantiating the fallback AnsiTerminal in build.dart, and accessing the private _toolContext field instead of the public getter toolContext in build_ios.dart for consistency.

Comment thread packages/flutter_tools/lib/src/commands/build.dart Outdated
Comment thread packages/flutter_tools/lib/src/commands/build_ios.dart Outdated
@github-actions github-actions Bot added team-android Owned by Android platform team team-windows Owned by the Windows platform team team-linux Owned by the Linux platform team labels Sep 3, 2026
Migrates `_toolContext` and `_appleContext` field extractions to Dart 3 object pattern destructuring in `BuildIOSArchiveCommand.runCommand`.
Migrates context field extractions to Dart 3 object pattern destructuring in `build_ios_framework.dart` and `build_macos_framework.dart`.
…lar context objects

Refactors XcodeCodeSigningSettings to provide context constructors
(XcodeCodeSigningSettings({required PlistParser plistParser, required ToolContext toolContext})
and XcodeCodeSigningSettings.fromContexts({required AppleContext appleContext, required ToolContext toolContext}))
instead of requiring callers to unpack 8+ individual arguments. Adds
DarwinAddToAppCodesigning.fromContexts and refactors BuildCommand to instantiate
codesigning from context objects and pass directly to subcommands.
@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 4, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Sep 4, 2026
Merged via the queue into flutter:master with commit a14d975 Sep 4, 2026
23 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Sep 4, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Sep 5, 2026
flutter/flutter@5a6cfa7...63170e9

2026-09-05 [email protected] Roll Dart SDK from 6882c3b4b542 to 77094991d1c1 (1 revision) (flutter/flutter#192339)
2026-09-05 [email protected] Roll Skia from 10652f9d64d6 to db200e27a634 (1 revision) (flutter/flutter#192338)
2026-09-05 [email protected] Roll Fuchsia Linux SDK from FgDQeF6jb1dVRVh3K... to _IgixhH4vEgdz9Oqn... (flutter/flutter#192333)
2026-09-05 [email protected] Roll Dart SDK from 5744c2480a12 to 6882c3b4b542 (1 revision) (flutter/flutter#192331)
2026-09-05 [email protected] Roll Skia from 9b1e5fd08d2c to 10652f9d64d6 (4 revisions) (flutter/flutter#192329)
2026-09-05 [email protected] ci(engine): target ignore_phone|none for new macs (flutter/flutter#192317)
2026-09-04 [email protected] [devicelab] Fix Mac ios_universal_link_test CI build and scheme configuration (flutter/flutter#192321)
2026-09-04 [email protected] Roll Dart SDK from 5501d02b583d to 5744c2480a12 (5 revisions) (flutter/flutter#192316)
2026-09-04 [email protected] [iOS] Add native deep link lifecycle integration tests for UIScene plugins (flutter/flutter#192173)
2026-09-04 [email protected] Roll Skia from 93ac1e630d1d to 9b1e5fd08d2c (3 revisions) (flutter/flutter#192314)
2026-09-04 [email protected] [tool] Migrate AssembleCommand and GenerateCommand to modular dependency injection (flutter/flutter#190773)
2026-09-04 [email protected] [tool] Migrate Apple build subcommands and toolchain to modular dependency injection (flutter/flutter#190780)
2026-09-04 [email protected] [flutter_tools] Safely handle non-JSON messages in test stream parsers (flutter/flutter#192089)
2026-09-04 [email protected] [tool] Migrate LogsCommand to modular dependency injection (flutter/flutter#190765)
2026-09-04 [email protected] [tool] Migrate DevicesCommand to modular dependency injection (flutter/flutter#190768)

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] 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
pull Bot pushed a commit to safarmer/flutter that referenced this pull request Sep 9, 2026
…dependency injection (flutter#192250)

## Summary

Part 15b of the modular dependency injection migration.

Migrates `BuildIOSCommand` and `BuildIOSArchiveCommand` (`flutter build
ios`, `flutter build ipa`) to modular dependency injection with
`ToolContext`, `AppleContext`, and `BuildSystem`, eliminating direct
dependencies on `globals.dart`.

Stacked on flutter#190780
Compare:
bkonyi/flutter@di/15-apple-build-and-toolchain...di/15b-ios-build-commands

Part of flutter#47161
victorsanni pushed a commit to victorsanni/packages that referenced this pull request Sep 9, 2026
…r#12767)

flutter/flutter@5a6cfa7...63170e9

2026-09-05 [email protected] Roll Dart SDK from 6882c3b4b542 to 77094991d1c1 (1 revision) (flutter/flutter#192339)
2026-09-05 [email protected] Roll Skia from 10652f9d64d6 to db200e27a634 (1 revision) (flutter/flutter#192338)
2026-09-05 [email protected] Roll Fuchsia Linux SDK from FgDQeF6jb1dVRVh3K... to _IgixhH4vEgdz9Oqn... (flutter/flutter#192333)
2026-09-05 [email protected] Roll Dart SDK from 5744c2480a12 to 6882c3b4b542 (1 revision) (flutter/flutter#192331)
2026-09-05 [email protected] Roll Skia from 9b1e5fd08d2c to 10652f9d64d6 (4 revisions) (flutter/flutter#192329)
2026-09-05 [email protected] ci(engine): target ignore_phone|none for new macs (flutter/flutter#192317)
2026-09-04 [email protected] [devicelab] Fix Mac ios_universal_link_test CI build and scheme configuration (flutter/flutter#192321)
2026-09-04 [email protected] Roll Dart SDK from 5501d02b583d to 5744c2480a12 (5 revisions) (flutter/flutter#192316)
2026-09-04 [email protected] [iOS] Add native deep link lifecycle integration tests for UIScene plugins (flutter/flutter#192173)
2026-09-04 [email protected] Roll Skia from 93ac1e630d1d to 9b1e5fd08d2c (3 revisions) (flutter/flutter#192314)
2026-09-04 [email protected] [tool] Migrate AssembleCommand and GenerateCommand to modular dependency injection (flutter/flutter#190773)
2026-09-04 [email protected] [tool] Migrate Apple build subcommands and toolchain to modular dependency injection (flutter/flutter#190780)
2026-09-04 [email protected] [flutter_tools] Safely handle non-JSON messages in test stream parsers (flutter/flutter#192089)
2026-09-04 [email protected] [tool] Migrate LogsCommand to modular dependency injection (flutter/flutter#190765)
2026-09-04 [email protected] [tool] Migrate DevicesCommand to modular dependency injection (flutter/flutter#190768)

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] 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
victorsanni pushed a commit to victorsanni/packages that referenced this pull request Sep 9, 2026
…r#12767)

flutter/flutter@5a6cfa7...63170e9

2026-09-05 [email protected] Roll Dart SDK from 6882c3b4b542 to 77094991d1c1 (1 revision) (flutter/flutter#192339)
2026-09-05 [email protected] Roll Skia from 10652f9d64d6 to db200e27a634 (1 revision) (flutter/flutter#192338)
2026-09-05 [email protected] Roll Fuchsia Linux SDK from FgDQeF6jb1dVRVh3K... to _IgixhH4vEgdz9Oqn... (flutter/flutter#192333)
2026-09-05 [email protected] Roll Dart SDK from 5744c2480a12 to 6882c3b4b542 (1 revision) (flutter/flutter#192331)
2026-09-05 [email protected] Roll Skia from 9b1e5fd08d2c to 10652f9d64d6 (4 revisions) (flutter/flutter#192329)
2026-09-05 [email protected] ci(engine): target ignore_phone|none for new macs (flutter/flutter#192317)
2026-09-04 [email protected] [devicelab] Fix Mac ios_universal_link_test CI build and scheme configuration (flutter/flutter#192321)
2026-09-04 [email protected] Roll Dart SDK from 5501d02b583d to 5744c2480a12 (5 revisions) (flutter/flutter#192316)
2026-09-04 [email protected] [iOS] Add native deep link lifecycle integration tests for UIScene plugins (flutter/flutter#192173)
2026-09-04 [email protected] Roll Skia from 93ac1e630d1d to 9b1e5fd08d2c (3 revisions) (flutter/flutter#192314)
2026-09-04 [email protected] [tool] Migrate AssembleCommand and GenerateCommand to modular dependency injection (flutter/flutter#190773)
2026-09-04 [email protected] [tool] Migrate Apple build subcommands and toolchain to modular dependency injection (flutter/flutter#190780)
2026-09-04 [email protected] [flutter_tools] Safely handle non-JSON messages in test stream parsers (flutter/flutter#192089)
2026-09-04 [email protected] [tool] Migrate LogsCommand to modular dependency injection (flutter/flutter#190765)
2026-09-04 [email protected] [tool] Migrate DevicesCommand to modular dependency injection (flutter/flutter#190768)

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] 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

a: desktop Running on desktop CICD Run CI/CD platform-ios iOS applications specifically team-android Owned by Android platform team team-ios Owned by iOS platform team team-linux Owned by the Linux platform team team-macos Owned by the macOS platform team team-windows Owned by the Windows platform team tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants