Skip to content

feat(flutter_tools): migrate Apple build commands to typed options - #192818

Merged
auto-submit[bot] merged 8 commits into
flutter:masterfrom
kevmoo:pr6-apple-build-options
Sep 25, 2026
Merged

auto-submit[bot] merged 8 commits into
flutter:masterfrom
kevmoo:pr6-apple-build-options

Conversation

@kevmoo

@kevmoo kevmoo commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Migrates Apple build subcommands (build ios, build ipa, build macos, build ios-framework, build macos-framework, and build swift-package) to use typed option descriptors and option bundles.

  • Adds BuildInfoOptions.codesignIdentity and DebuggingOptionDescriptors.publishPort descriptors.
  • Adds AppleBuildOptionsBundle for common Apple compilation and build options (flavor, splitDebugInfo, obfuscate, extraFrontEndOptions, extraGenSnapshotOptions, performanceMeasurementFile, analyzeSize, and codeSizeDirectory).
  • Adds DarwinCodeSignXCFrameworksOptionsBundle composing codesign and codesignIdentity.
  • Removes obsolete usesDarwinCodeSignXCFrameworksOption helper from FlutterCommand as all callers (build ios-framework, build macos-framework, build swift-package) have migrated.
  • Updates FlutterCommand.addPublishPort and FlutterCommand.disablePortPublication to use DebuggingOptionDescriptors.publishPort.
  • Migrates command constructors to registerOptionBundles and argParser.addDescriptors.
  • Migrates option reads to getValue(...) / wasParsed(...) via SafeArgResults.
  • Adds unit tests for AppleBuildOptionsBundle and DarwinCodeSignXCFrameworksOptionsBundle in option_descriptor_test.dart.

Pre-launch Checklist

@github-actions github-actions Bot added tool Affects the "flutter" command-line tool. See also t: labels. team-ios Owned by iOS platform team team-macos Owned by the macOS platform team labels Sep 15, 2026
@kevmoo
kevmoo marked this pull request as ready for review September 15, 2026 19:50
@kevmoo
kevmoo requested review from a team as code owners September 15, 2026 19:50

@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 command-line option registration across several Apple-related build commands to use a structured, descriptor-based approach with OptionDescriptor and OptionBundle. A critical compilation issue was identified in DarwinAddToAppOptionsBundle.onRegister, where the non-existent methods enableUsesTargetOption and enableUsesPubOption are called on FlutterCommand instead of usesTargetOption and usesPubOption.

Comment thread packages/flutter_tools/lib/src/runner/options/common_options.dart
@kevmoo kevmoo added the CICD Run CI/CD label Sep 18, 2026
…ions

# Conflicts:
#	packages/flutter_tools/lib/src/commands/build_ios.dart
#	packages/flutter_tools/lib/src/commands/build_macos.dart
@okorohelijah

Copy link
Copy Markdown
Contributor

@kevmoo some tests are failing:

02:12 +3 -1: test/integration.shard/swift_package_manager_add2app_test.dart: Generate and embed Flutter app in native macos app using SwiftPM [E]
  Expected: not <Instance of 'FileSystemEntity'> with `existsSync`: <true>
    Actual: LocalDirectory:<LocalDirectory: '/Volumes/Work/s/w/ir/x/t/swift_package_manager_add2app_test_macos.vKt8VK/my_flutter_app/build/macos/SwiftPackages/FlutterNativeIntegration/FlutterNativeTools/Tests'>
  
  package:matcher                                                        expect
  test/integration.shard/swift_package_manager_add2app_test.dart 640:3   _verifyModeAgnosticFiles
  test/integration.shard/swift_package_manager_add2app_test.dart 144:11  main.<fn>
06:14 +4 -2: test/integration.shard/swift_package_manager_add2app_test.dart: Generate and embed Flutter app in native ios app using SwiftPM [E]
  Expected: not <Instance of 'FileSystemEntity'> with `existsSync`: <true>
    Actual: LocalDirectory:<LocalDirectory: '/Volumes/Work/s/w/ir/x/t/swift_package_manager_add2app_test_ios.wYWcUh/my_flutter_app/build/ios/SwiftPackages/FlutterNativeIntegration/FlutterNativeTools/Tests'>
  
  package:matcher                                                        expect
  test/integration.shard/swift_package_manager_add2app_test.dart 640:3   _verifyModeAgnosticFiles
  test/integration.shard/swift_package_manager_add2app_test.dart 144:11  main.<fn>

…ateTests

`BuildSwiftPackage.generateTests` previously checked `boolArg('ci', global: true)`,
which is only true when `--ci` is explicitly passed on the command line.
Using `usingCISystem` caused `generateTests` to return `true` whenever
`LUCI_CI=True` was set in the environment on LUCI bots (breaking
`swift_package_manager_add2app_test.dart` in `Mac tool_integration_tests_8`).

- Add `CommonOptions.ci` (`OptionScope.global`) for `--ci` and register it in `FlutterCommandRunner`.
- Update `FlutterCommand.usingCISystem` and `BuildSwiftPackage.generateTests` to read `getValue(CommonOptions.ci)`.
- Add hermetic regression test in `build_swift_package_test.dart`.
@kevmoo

kevmoo commented Sep 24, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for flagging, @okorohelijah! Fixed in 45abce6.

Root cause: BuildSwiftPackage.generateTests originally checked boolArg(FlutterGlobalOptions.kContinuousIntegrationFlag, global: true), which is true only when --ci is explicitly passed on the CLI. Switching it to usingCISystem caused generateTests to also return true whenever LUCI_CI=True is set in the environment on LUCI bots, unexpectedly generating FlutterNativeIntegration/FlutterNativeTools/Tests during swift_package_manager_add2app_test.dart.

We added a typed global descriptor CommonOptions.ci (OptionScope.global), updated both FlutterCommand.usingCISystem and BuildSwiftPackage.generateTests to read getValue(CommonOptions.ci), and added a hermetic regression test in build_swift_package_test.dart.

@kevmoo
kevmoo requested a review from bkonyi September 24, 2026 20:08
@kevmoo kevmoo added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 24, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Sep 25, 2026
Merged via the queue into flutter:master with commit c990a63 Sep 25, 2026
23 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Sep 25, 2026
@kevmoo
kevmoo deleted the pr6-apple-build-options branch September 25, 2026 03:18
flutter-zl pushed a commit to flutter-zl/flutter that referenced this pull request Oct 8, 2026
…lutter#193323)

Migrate `BuildLinuxCommand` (`build linux`) and `BuildWindowsCommand`
(`build windows`) to typed `OptionDescriptor`s and `OptionBundle`s
(following flutter#191018, flutter#191510, flutter#191760, flutter#192307, flutter#192455, flutter#192524, and
flutter#192818):

- Add `DesktopBuildOptionsBundle` in `common_options.dart`,
encapsulating `CommonBuildOptionsBundle`, `BuildModeOptionsBundle`,
`DartCompileOptionsBundle`, `BuildInfoOptions.flavor`, `splitDebugInfo`,
`obfuscate`, `extraFrontEndOptions`, `extraGenSnapshotOptions`,
`performanceMeasurementFile`, `analyzeSize`, `codeSizeDirectory`,
`trackWidgetCreation`, and `configOnly`.
- Migrate `BuildLinuxCommand` (`build_linux.dart`) to
`DesktopBuildOptionsBundle`,
`DefaultedEnumOptionDescriptor<TargetPlatform>`
(`_targetPlatformOption`), and `DefaultedStringOptionDescriptor`
(`_targetSysroot`), replacing untyped `boolArg('config-only')`,
`stringArg('target-platform')!`, and `stringArg('target-sysroot')!`
queries.
- Migrate `BuildWindowsCommand` (`build_windows.dart`) to
`DesktopBuildOptionsBundle` and
`getValue(DesktopBuildOptionsBundle.configOnly)`.
- Delete the obsolete `FlutterCommand.addCommonDesktopBuildOptions`
helper method from `flutter_command.dart` (no remaining callers in
`flutter_tools`).

## 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].
- [ ] 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD 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