Skip to content

[flutter_tools] Migrate iOS devices, simulators, emulators, and XCDevice away from globals - #193651

Open
bkonyi wants to merge 3 commits into
flutter:masterfrom
bkonyi:di/28c-ios-devices-and-simulators
Open

bkonyi wants to merge 3 commits into
flutter:masterfrom
bkonyi:di/28c-ios-devices-and-simulators

Conversation

@bkonyi

@bkonyi bkonyi commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Migrates iOS devices, simulators, emulators, CoreDeviceControl, XcodeDebug, and XCDevice away from globals.dart to explicit dependency injection.

Part of #188471

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.

@bkonyi
bkonyi requested review from a team as code owners October 1, 2026 15:08
@bkonyi bkonyi added tool Affects the "flutter" command-line tool. See also t: labels. CICD Run CI/CD labels Oct 1, 2026
@github-actions github-actions Bot added platform-ios iOS applications specifically platform-macos Building on or for macOS specifically a: desktop Running on desktop team-ios Owned by iOS platform team team-macos Owned by the macOS platform team labels Oct 1, 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 multiple iOS-related classes in flutter_tools to replace global state access with explicit dependency injection. Key components, including EmulatorManager, IOSDevice, IOSSimulator, LLDB, and XCDevice, now accept dependencies such as Xcode, Platform, FileSystem, and OperatingSystemUtils directly. The reviewer suggests further improvements to simplify constructors, remove redundant dependencies like XcodeProjectInterpreter, and enhance test hermeticity by making certain parameters required rather than relying on fallback logic.

Comment thread packages/flutter_tools/lib/src/ios/simulators.dart
Comment thread packages/flutter_tools/lib/src/ios/ios_emulators.dart Outdated
Comment thread packages/flutter_tools/lib/src/ios/lldb.dart Outdated
Comment thread packages/flutter_tools/lib/src/ios/devices.dart Outdated
@bkonyi
bkonyi marked this pull request as draft October 1, 2026 15:23
@flutter-dashboard

Copy link
Copy Markdown

This pull request has been changed to a draft. The currently pending flutter-gold status will not be able to resolve until a new commit is pushed or the change is marked ready for review again.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@bkonyi
bkonyi marked this pull request as ready for review October 2, 2026 16:52

@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 iOS-related classes and tools in the Flutter tool codebase to replace global variable usages with constructor-injected dependencies, enhancing testability. The review feedback highlights several opportunities to improve this dependency injection, such as storing and passing the injected ProcessManager in IOSSimulatorUtils, using the non-nullable _shutdownHooks instance field instead of the nullable parameter in IOSDevice, making the Logger parameter required in IOSEmulators and IOSEmulator, and removing an invalid const constructor from IOSEmulator.

Comment thread packages/flutter_tools/lib/src/ios/simulators.dart
Comment thread packages/flutter_tools/lib/src/ios/simulators.dart
Comment thread packages/flutter_tools/lib/src/ios/devices.dart
Comment thread packages/flutter_tools/lib/src/ios/devices.dart
Comment thread packages/flutter_tools/lib/src/ios/ios_emulators.dart Outdated
Comment thread packages/flutter_tools/lib/src/ios/ios_emulators.dart Outdated
Comment thread packages/flutter_tools/lib/src/ios/devices.dart
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 platform-macos Building on or for macOS specifically team-ios Owned by iOS platform team team-macos Owned by the macOS 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.

1 participant