Skip to content

[flutter_tools] Remove globals from macOS build, migration, and Xcode project - #193652

Merged
auto-submit[bot] merged 26 commits into
flutter:masterfrom
bkonyi:di/28d-macos-build-and-xcode-project
Oct 28, 2026
Merged

auto-submit[bot] merged 26 commits into
flutter:masterfrom
bkonyi:di/28d-macos-build-and-xcode-project

Conversation

@bkonyi

@bkonyi bkonyi commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Migrates macOS build utilities, XcodeProjectInterpreter, IosProject, MacOSProject, and XcodeProjectMigration away from globals.dart to explicit dependency injection via ToolContext.

Part of #47161

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.

… project

Inject dependencies into FlutterApplicationMigration, buildMacOS, and XcodeBasedProject (IosProject and MacOSProject) to remove direct globals.dart usages.
@bkonyi
bkonyi requested a review from a team as a code owner 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
@bkonyi
bkonyi requested a review from a team as a code owner October 1, 2026 15:08
@github-actions github-actions Bot added 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 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.

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

bkonyi added 6 commits October 3, 2026 02:08
…ix FlutterProject.fromDirectoryTest logger fallback
# Conflicts:
#	packages/flutter_tools/test/commands.shard/hermetic/update_packages_test.dart
# Conflicts:
#	packages/flutter_tools/lib/src/context/tool_dependencies.dart
…test

Removes the bare FlutterProjectFactory override in createCreateCommand so FakeToolContext uses its default FlutterProjectFactory configured with FakePlistParser, FakeXcode, and FakeXcodeProjectInterpreter.
@flutter-dashboard flutter-dashboard Bot added the will affect goldens Changes to golden files label Oct 23, 2026
@LongCatIsLooong
LongCatIsLooong removed the request for review from okorohelijah October 23, 2026 21:46
@LongCatIsLooong
LongCatIsLooong dismissed okorohelijah’s stale review October 23, 2026 21:47

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
@bkonyi
bkonyi requested a review from chingjun October 28, 2026 19:23
@bkonyi bkonyi removed the will affect goldens Changes to golden files label Oct 28, 2026
@bkonyi bkonyi added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 28, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Oct 28, 2026
Merged via the queue into flutter:master with commit 6da6a9b Oct 28, 2026
24 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Oct 28, 2026
@hellohuanlin

hellohuanlin commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Reason for revert:

Broken tree seems to be caused by this PR:

rc/tmphs_oembv/flutter%20sdk/packages/flutter_tools/lib/src/macos/build_macos.dart:234:16: Error: Undefined name 'globals'.
    cocoaPods: globals.cocoaPods,

@hellohuanlin hellohuanlin added the revert Autorevert PR (with "Reason for revert:" comment) label Oct 28, 2026
@flutteractionsbot

Copy link
Copy Markdown
Contributor

Successfully created revert PR: #195535

@flutteractionsbot flutteractionsbot removed the revert Autorevert PR (with "Reason for revert:" comment) label Oct 28, 2026
kevmoo pushed a commit to kevmoo/flutter that referenced this pull request Oct 29, 2026
…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.
Rheoz pushed a commit to Rheoz/flutter that referenced this pull request Oct 29, 2026
…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
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.

5 participants