Skip to content

Revert: [flutter_tools] Remove globals from macOS build, migration, and Xcode project - #195535

Merged
jtmcdole merged 1 commit into
flutter:masterfrom
flutteractionsbot:revert-193652-1793226157
Oct 29, 2026
Merged

jtmcdole merged 1 commit into
flutter:masterfrom
flutteractionsbot:revert-193652-1793226157

Conversation

@flutteractionsbot

Copy link
Copy Markdown
Contributor

Reverts: [flutter_tools] Remove globals from macOS build, migration, and Xcode project

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

@flutteractionsbot
flutteractionsbot requested a review from a team as a code owner October 28, 2026 22:22
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Oct 28, 2026
@flutteractionsbot
flutteractionsbot requested a review from a team as a code owner October 28, 2026 22:22
@github-actions github-actions Bot added platform-ios iOS applications specifically tool Affects the "flutter" command-line tool. See also t: labels. 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 28, 2026
@jtmcdole jtmcdole added the emergency Jump the queue; land PR in front of all others; only use for emergencies label Oct 28, 2026
@flutter-dashboard

Copy link
Copy Markdown

Detected the emergency label.

If you add the autosubmit label, the bot will wait until all presubmits pass but ignore the tree status, allowing fixes for tree breakages while still validating that they don't break any existing presubmits.

The "Merge" button is also unlocked. To bypass presubmits as well as the tree status, press the GitHub "Add to Merge Queue".

@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 flutter_tools package to remove the AppleContext dependency from several classes, including BuildMacosCommand, MacOSDevice, and SwiftPackageManagerIntegrationMigration. It introduces a more direct usage of globals for dependencies like logger, fileSystem, and plistParser to simplify dependency injection. Additionally, it updates the FlutterProjectFactory constructor and its usage across the codebase. Several critical issues were identified regarding constructor parameter naming and inconsistent use of local variables versus global accessors.

/// A wrapper around the `flutter` section in the `pubspec.yaml` file.
class FlutterManifest {
FlutterManifest._({required this.logger});
FlutterManifest._({required this._logger});

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.

critical

Changing the constructor parameter to this._logger makes the named parameter _logger instead of logger. This causes a compile-time error in the redirecting factory constructor FlutterManifest.empty (which expects logger) and in the constructor invocation at line 86 (FlutterManifest._(logger: _logger)). To fix this, define the constructor parameter as logger and initialize the private field _logger in the initializer list.

  FlutterManifest._({required Logger logger}) : _logger = logger;

this._xcodeProjectInterpreter,
this._xcodeProjectInterpreterBuilder,
});
FlutterProjectFactory({required this._logger, required this._fileSystem, this._config});

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.

critical

Changing the constructor parameters to this._logger and this._fileSystem makes the named parameters _logger and _fileSystem instead of logger and fileSystem. This breaks every single instantiation of FlutterProjectFactory across the codebase (including in globals.dart, tool_dependencies.dart, and numerous tests) with compile-time errors. To fix this, define the constructor with public parameter names logger and fileSystem, and initialize the private fields in the initializer list.

Suggested change
FlutterProjectFactory({required this._logger, required this._fileSystem, this._config});
FlutterProjectFactory({
required Logger logger,
required FileSystem fileSystem,
Config? config,
}) : _logger = logger,
_fileSystem = fileSystem,
_config = config;

Comment on lines +131 to +133
fileSystem: globals.fs,
plistParser: globals.plistParser,
config: globals.config,

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.

medium

Since fs and config are already destructured from toolContext at the beginning of buildMacOS (line 93), we should consistently use these local variables instead of falling back to globals.fs and globals.config.

Suggested change
fileSystem: globals.fs,
plistParser: globals.plistParser,
config: globals.config,
fileSystem: fs,
plistParser: globals.plistParser,
config: config,

logger: logger,
cocoapods: cocoaPods,
analytics: analytics,
fileSystem: globals.fs,

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.

medium

Use the destructured local variable fs instead of globals.fs for consistency.

Suggested change
fileSystem: globals.fs,
fileSystem: fs,

// regardless of the project name so long as there is exactly one project.
final String? xcodeProjectName = xcodeProject.existsSync() ? xcodeProject.basename : null;
final XcodeProjectInfo? projectInfo = await xcodeProjectInterpreter.getInfo(
final XcodeProjectInfo? projectInfo = await globals.xcodeProjectInterpreter?.getInfo(

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.

medium

Since globals.xcodeProjectInterpreter is checked for null and guaranteed to be non-null at line 103, use ! instead of ?. to be consistent with other usages in this file.

Suggested change
final XcodeProjectInfo? projectInfo = await globals.xcodeProjectInterpreter?.getInfo(
final XcodeProjectInfo? projectInfo = await globals.xcodeProjectInterpreter!.getInfo(

.fetchDependenciesAndGenerateXcodebuildArgs(
flutterProject.macos,
fs.directory(buildDirectoryPath),
globals.fs.directory(buildDirectoryPath),

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.

medium

Use the destructured local variable fs instead of globals.fs for consistency.

Suggested change
globals.fs.directory(buildDirectoryPath),
fs.directory(buildDirectoryPath),

Comment on lines +325 to +326
'OBJROOT=${globals.fs.path.join(flutterBuildDir.absolute.path, 'Build', 'Intermediates.noindex')}',
'SYMROOT=${globals.fs.path.join(flutterBuildDir.absolute.path, 'Build', 'Products')}',

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.

medium

Use the destructured local variable fs instead of globals.fs for consistency.

Suggested change
'OBJROOT=${globals.fs.path.join(flutterBuildDir.absolute.path, 'Build', 'Intermediates.noindex')}',
'SYMROOT=${globals.fs.path.join(flutterBuildDir.absolute.path, 'Build', 'Products')}',
'OBJROOT=${fs.path.join(flutterBuildDir.absolute.path, 'Build', 'Intermediates.noindex')}',
'SYMROOT=${fs.path.join(flutterBuildDir.absolute.path, 'Build', 'Products')}',

final File? aotSnapshot = const <CpuArch>[CpuArch.armv7, CpuArch.arm64, CpuArch.x64]
.map<File?>((CpuArch arch) {
return fileSystem
return globals.fs

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.

medium

Use the destructured local variable fs instead of globals.fs for consistency within _writeCodeSizeAnalysis.

Suggested change
return globals.fs
return fs

final File? precompilerTrace = const <CpuArch>[CpuArch.armv7, CpuArch.arm64, CpuArch.x64]
.map<File?>((CpuArch arch) {
return fileSystem
return globals.fs

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.

medium

Use the destructured local variable fs instead of globals.fs for consistency within _writeCodeSizeAnalysis.

Suggested change
return globals.fs
return fs

Directory directory,
) {
return fileSystem.path.extension(directory.path) == '.app';
return globals.fs.path.extension(directory.path) == '.app';

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.

medium

Use the destructured local variable fs instead of globals.fs for consistency within _writeCodeSizeAnalysis.

Suggested change
return globals.fs.path.extension(directory.path) == '.app';
return fs.path.extension(directory.path) == '.app';

@bkonyi
bkonyi self-requested a review October 28, 2026 22:57
@jtmcdole
jtmcdole added this pull request to the merge queue Oct 28, 2026
Merged via the queue into flutter:master with commit 8bf6f10 Oct 29, 2026
27 of 28 checks passed
@flutteractionsbot
flutteractionsbot deleted the revert-193652-1793226157 branch October 29, 2026 02:09
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 emergency Jump the queue; land PR in front of all others; only use for emergencies 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.

3 participants