Repository navigation
[flutter_tools] Remove globals from macOS build, migration, and Xcode project - #193652
auto-submit[bot] merged 26 commits into
Conversation
… project Inject dependencies into FlutterApplicationMigration, buildMacOS, and XcodeBasedProject (IosProject and MacOSProject) to remove direct globals.dart usages.
There was a problem hiding this comment.
Code Review
This pull request refactors the macOS build command and related project classes to inject dependencies (such as FileSystem, Logger, and XcodeProjectInterpreter) instead of relying on global variables, updating corresponding tests to match the new signatures. The review feedback highlights a potential regression where buildMacOS is called in MacOSDevice without passing flutterVersion, which would silently skip the Swift Package Manager integration migration during macOS device builds; it suggests injecting and passing FlutterVersion to resolve this.
|
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 Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
…and inject FlutterVersion into MacOSDevice
…and-xcode-project
There was a problem hiding this comment.
Code Review
This pull request refactors the macOS build and device management code to explicitly pass ToolContext and other dependencies instead of relying on global variables. However, several critical compile-time errors were identified in the constructors of XcodeBasedProject, FlutterProject, IosProject.fromFlutter, and MacOSDevice. In Dart, using private fields as named parameters (such as this._logger) makes the parameters private and inaccessible from outside the class or library. These constructors should be updated to use public parameter names and initialize the private fields in the initializer list.
…ix FlutterProject.fromDirectoryTest logger fallback
…and-xcode-project
# Conflicts: # packages/flutter_tools/test/commands.shard/hermetic/update_packages_test.dart
# Conflicts: # packages/flutter_tools/lib/src/context/tool_dependencies.dart
…utterProject and XcodeBasedProject
…and-xcode-project
…test Removes the bare FlutterProjectFactory override in createCreateCommand so FakeToolContext uses its default FlutterProjectFactory configured with FakePlistParser, FakeXcode, and FakeXcodeProjectInterpreter.
Victoria is going to take this over
…and-xcode-project # Conflicts: # packages/flutter_tools/lib/src/commands/build_macos.dart # packages/flutter_tools/lib/src/context/tool_dependencies.dart # packages/flutter_tools/lib/src/globals.dart # packages/flutter_tools/lib/src/ios/mac.dart # packages/flutter_tools/lib/src/macos/build_macos.dart # packages/flutter_tools/lib/src/macos/macos_device.dart # packages/flutter_tools/lib/src/project.dart # packages/flutter_tools/lib/src/xcode_project.dart # packages/flutter_tools/test/commands.shard/hermetic/build_macos_test.dart # packages/flutter_tools/test/general.shard/xcode_project_test.dart # packages/flutter_tools/test/src/fake_build_command.dart # packages/flutter_tools/test/src/fakes.dart
…and-xcode-project # Conflicts: # packages/flutter_tools/lib/src/context/tool_dependencies.dart
|
Reason for revert: Broken tree seems to be caused by this PR: |
|
Successfully created revert PR: #195535 |
…nd Xcode project (flutter#195535) Reverts: [[flutter_tools] Remove globals from macOS build, migration, and Xcode project](flutter#193652) Initiated by: @hellohuanlin Reason for reverting: ``` Original PR Author: @bkonyi Reviewed By: @chingjun The original PR description is provided below: Migrates macOS build utilities, `XcodeProjectInterpreter`, `IosProject`, `MacOSProject`, and `XcodeProjectMigration` away from `globals.dart` to explicit dependency injection via `ToolContext`. Part of flutter#47161 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] All existing and new tests are passing.
…nd Xcode project" (flutter#195552) Relands flutter#193652, which was reverted in flutter#195535 due to a semantic merge conflict with flutter#194052: `runMacOSPodInstall` in `build_macos.dart` referenced `globals.cocoaPods` and `globals.templateRenderer` after the `globals.dart` import was removed. This reland fixes the conflict by passing the injected `cocoaPods` and threading `required TemplateRenderer templateRenderer` into `buildMacOS`, `BuildMacosCommand`, `MacOSDevice`, `MacOSDevices`, and `FlutterDeviceManager`. Part of flutter#47161 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
Migrates macOS build utilities,
XcodeProjectInterpreter,IosProject,MacOSProject, andXcodeProjectMigrationaway fromglobals.dartto explicit dependency injection viaToolContext.Part of #47161
Pre-launch Checklist
///).