Skip to content

[tool] Update Swift Package Manager handling#11234

Merged
auto-submit[bot] merged 3 commits intoflutter:mainfrom
stuartmorgan-g:swiftpm-update-repo-tool-handling
Mar 12, 2026
Merged

[tool] Update Swift Package Manager handling#11234
auto-submit[bot] merged 3 commits intoflutter:mainfrom
stuartmorgan-g:swiftpm-update-repo-tool-handling

Conversation

@stuartmorgan-g
Copy link
Collaborator

Updates the repo tooling for Swift Package manager being on by default on main, and for analysis now working with Swift Package Manager:

  • Explicitly disables SwiftPM for the build-all test, instead of relying on it being off by default
  • No longer disable SwiftPM for example apps before running analysis, since it's no longer necessary to do so, and we don't want to rely on CocoaPods for core tests going forward.

Fixes flutter/flutter#183521
Fixes flutter/flutter#172427

@stuartmorgan-g stuartmorgan-g added the CICD Run CI/CD label Mar 12, 2026
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

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 updates the repository tooling for Swift Package Manager. It introduces a --swift-package-manager flag (with its negation) to the create-all-packages-app command, allowing explicit control over SPM usage. This new flag is used in CI configurations for ios_build_all_packages and macos_build_all_packages to disable SPM. The change also removes the now-unnecessary logic that disabled SPM during the analyze command for example apps. Corresponding test files are updated to reflect these changes, with new tests for the create-all-packages-app command and removal of obsolete tests for the analyze command.

Comment on lines +500 to +526
test('disables Swift Package Manager if requested', () async {
writeFakeFlutterCreateOutput(testRoot);
createFakePlugin('plugina', packagesDir);

await runCapturingPrint(runner, <String>[
'create-all-packages-app',
'--no-swift-package-manager',
]);

final Pubspec pubspec = command.app.parsePubspec();
final flutterConfig = pubspec.flutter?['config'] as YamlMap?;
expect(flutterConfig?['enable-swift-package-manager'], false);
});

test('enables Swift Package Manager if requested', () async {
writeFakeFlutterCreateOutput(testRoot);
createFakePlugin('plugina', packagesDir);

await runCapturingPrint(runner, <String>[
'create-all-packages-app',
'--swift-package-manager',
]);

final Pubspec pubspec = command.app.parsePubspec();
final flutterConfig = pubspec.flutter?['config'] as YamlMap?;
expect(flutterConfig?['enable-swift-package-manager'], true);
});

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

These two tests are very similar and contain duplicated setup code. To improve readability and reduce duplication, you could group them under a group and use a setUp block for the common initialization.

    group('Swift Package Manager flag', () {
      setUp(() {
        writeFakeFlutterCreateOutput(testRoot);
        createFakePlugin('plugina', packagesDir);
      });

      test('disables if requested', () async {
        await runCapturingPrint(runner, <String>[
          'create-all-packages-app',
          '--no-swift-package-manager',
        ]);

        final Pubspec pubspec = command.app.parsePubspec();
        final flutterConfig = pubspec.flutter?['config'] as YamlMap?;
        expect(flutterConfig?['enable-swift-package-manager'], false);
      });

      test('enables if requested', () async {
        await runCapturingPrint(runner, <String>[
          'create-all-packages-app',
          '--swift-package-manager',
        ]);

        final Pubspec pubspec = command.app.parsePubspec();
        final flutterConfig = pubspec.flutter?['config'] as YamlMap?;
        expect(flutterConfig?['enable-swift-package-manager'], true);
      });
    });

@stuartmorgan-g stuartmorgan-g added CICD Run CI/CD autosubmit Merge PR when tree becomes green via auto submit App and removed CICD Run CI/CD labels Mar 12, 2026
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Mar 12, 2026
@auto-submit
Copy link
Contributor

auto-submit bot commented Mar 12, 2026

autosubmit label was removed for flutter/packages/11234, because - The status or check suite Linux_web web_platform_tests_wasm_shard_3 master has failed. Please fix the issues identified (or deflake) before re-applying this label.

@stuartmorgan-g stuartmorgan-g added the autosubmit Merge PR when tree becomes green via auto submit App label Mar 12, 2026
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Mar 12, 2026
@auto-submit
Copy link
Contributor

auto-submit bot commented Mar 12, 2026

autosubmit label was removed for flutter/packages/11234, because - The status or check suite Mac_arm64 ios_platform_tests_shard_3 master has failed. Please fix the issues identified (or deflake) before re-applying this label.

@stuartmorgan-g
Copy link
Collaborator Author

autosubmit label was removed for flutter/packages/11234, because - The status or check suite Mac_arm64 ios_platform_tests_shard_3 master has failed. Please fix the issues identified (or deflake) before re-applying this label.

This is the existing IAP flake, unrelated to this PR.

@stuartmorgan-g stuartmorgan-g added the autosubmit Merge PR when tree becomes green via auto submit App label Mar 12, 2026
@auto-submit auto-submit bot merged commit 86543fa into flutter:main Mar 12, 2026
81 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 13, 2026
github-merge-queue bot pushed a commit to flutter/flutter that referenced this pull request Mar 13, 2026
flutter/packages@02f231f...91f7c33

2026-03-12 [email protected] Roll Flutter from
3f400d7 to 9e36adb (21 revisions) (flutter/packages#11233)
2026-03-12 [email protected] [tool] Update Swift Package Manager
handling (flutter/packages#11234)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC [email protected] on the revert to ensure that a
human
is aware of the problem.

To file a bug in Flutter:
https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App CICD Run CI/CD

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[packages] Disable Swift Package Manager for the build-all test [packages] Design analysis solution for SwiftPM packages

2 participants