Show SwiftPM warnings right before iOS/macOS build#185984
Conversation
…yForPlatformSpecificTooling
There was a problem hiding this comment.
Code Review
This pull request refactors DarwinDependencyManagement by removing instance-level dependencies on the logger and platform, and introduces a static validatePluginSupport method to handle plugin compatibility checks for iOS and macOS builds. Feedback highlights potential runtime crashes caused by forced null-assertions on globals.cocoaPods in environments where CocoaPods is not installed. It is also recommended to refactor _countPluginsPerManager to be synchronous, as the method no longer contains asynchronous operations.
I am having trouble creating individual review comments. Click here to see my feedback.
packages/flutter_tools/lib/src/ios/mac.dart (200-207)
Using the null check operator (!) on globals.cocoaPods is risky here. If a user does not have CocoaPods installed on their macOS host, globals.cocoaPods will be null, causing the tool to crash with a Null check operator used on a null value error during the build process. It is safer to pass it as a nullable argument and handle the null case within validatePluginSupport to provide a better user experience or skip CocoaPods-specific checks.
await DarwinDependencyManagement.validatePluginSupport(
platform: darwinPlatform,
xcodeProject: project.ios,
plugins: await project.ios.getPlugins(),
fileSystem: globals.fs,
logger: globals.logger,
cocoapods: globals.cocoaPods,
);
packages/flutter_tools/lib/src/macos/build_macos.dart (116-123)
Similar to the iOS build path, using globals.cocoaPods! here can lead to a crash if CocoaPods is not installed on the host machine. Removing the bang operator and allowing validatePluginSupport to handle a null cocoapods instance is more robust.
await DarwinDependencyManagement.validatePluginSupport(
platform: darwinPlatform,
xcodeProject: flutterProject.macos,
plugins: await flutterProject.macos.getPlugins(),
fileSystem: globals.fs,
logger: globals.logger,
cocoapods: globals.cocoaPods,
);
packages/flutter_tools/lib/src/macos/darwin_dependency_management.dart (185-192)
To avoid potential crashes when CocoaPods is not installed, cocoapods should be an optional parameter. This allows the build to proceed with SwiftPM-only checks even if the CocoaPods service is unavailable.
static Future<void> validatePluginSupport({
required FlutterDarwinPlatform platform,
required XcodeBasedProject xcodeProject,
required List<Plugin> plugins,
required FileSystem fileSystem,
required Logger logger,
CocoaPods? cocoapods,
}) async {
packages/flutter_tools/lib/src/macos/darwin_dependency_management.dart (304-313)
Update this helper to accept a nullable CocoaPods instance and return early if it is null. This ensures that CocoaPods-specific migration warnings are only attempted when the CocoaPods tool is actually available on the system.
static Future<void> _printRemoveCocoapodIntegrationMessage({
CocoaPods? cocoapods,
required XcodeBasedProject xcodeProject,
required Logger logger,
required FlutterDarwinPlatform platform,
required List<String> cocoapodOnlyPlugins,
required bool projectUsesSwiftPM,
}) async {
if (cocoapods == null || !projectUsesSwiftPM || cocoapodOnlyPlugins.isNotEmpty) {
return;
}
packages/flutter_tools/lib/src/macos/darwin_dependency_management.dart (143-146)
The _countPluginsPerManager method no longer performs any asynchronous operations (like fetching Podfile templates). It can be refactored to be synchronous for better efficiency and clarity.
({int totalCount, int swiftPackageCount, int podCount}) _countPluginsPerManager({
required FlutterDarwinPlatform platform,
required XcodeBasedProject xcodeProject,
}) {
packages/flutter_tools/lib/src/macos/darwin_dependency_management.dart (98-101)
If _countPluginsPerManager is refactored to be synchronous, the await keyword should be removed here.
final (:int totalCount, :int swiftPackageCount, :int podCount) = _countPluginsPerManager(
platform: platform,
xcodeProject: xcodeProject,
);
| /// - Warns when using CocoaPod-only plugins | ||
| /// - Warns when CocoaPods integration is removable | ||
| /// - Warns when building a plugin example app that doesn't support SwiftPM | ||
| static Future<void> validatePluginSupport({ |
There was a problem hiding this comment.
I didn't look too closely, but I assume here is just moving warning logic from setup (called in ensureReadyForPlatformSpecificTooling) to validatePluginSupport (called when xcodebuild)? If so, LGTM.
Roll Flutter from 707dbc0420a3 to 23f6f5853f50 (149 revisions) flutter/flutter@707dbc0...23f6f58 2026-05-12 737941+loic-sharma@users.noreply.github.com Add 'cp: review' label to the manual cherrypick process (flutter/flutter#186158) 2026-05-12 engine-flutter-autoroll@skia.org Roll Packages from 19ec8b8 to 93cbed6 (3 revisions) (flutter/flutter#186401) 2026-05-12 30870216+gaaclarke@users.noreply.github.com Removes SDF option for macOS (always enabled) (flutter/flutter#186265) 2026-05-12 nico.reiab@gmail.com docs: fix typos in flutter_tools comments (flutter/flutter#186321) 2026-05-12 15619084+vashworth@users.noreply.github.com Pass XcodeBasedProject instead of String to functions in XcodeProjectInterpreter (flutter/flutter#186378) 2026-05-12 jason-simmons@users.noreply.github.com Update iOS scenario app test goldens to match changes from flutter/flutter#182662 (flutter/flutter#186390) 2026-05-12 engine-flutter-autoroll@skia.org Roll Skia from ad0aff15b9fa to 77a21bc723dc (2 revisions) (flutter/flutter#186396) 2026-05-12 32538273+ValentinVignal@users.noreply.github.com Migrate focus_node.unfocus.0.dart to use `RadioGroup` (flutter/flutter#183979) 2026-05-12 engine-flutter-autoroll@skia.org Roll Skia from 91d3c1e730af to ad0aff15b9fa (7 revisions) (flutter/flutter#186391) 2026-05-12 bdero@google.com [Flutter GPU] Allow customizing the vertex layout on a RenderPipeline (flutter/flutter#186310) 2026-05-12 97480502+b-luk@users.noreply.github.com Fix `EmbedderTest.CanRenderTextWithImpellerMetal` test breakage (flutter/flutter#186262) 2026-05-12 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from rFhU-YPqdCRCtCz7b... to z7ICmPtn4hspu02zk... (flutter/flutter#186384) 2026-05-12 bdero@google.com [Impeller] GLES: lazily allocate texture mip levels on first per-level write (flutter/flutter#186302) 2026-05-12 bdero@google.com [Android] Propagate --enable-flutter-gpu Intent extra to engine args (flutter/flutter#186298) 2026-05-11 47866232+chunhtai@users.noreply.github.com [ci] update no-response workflow to also look for old label name in e… (flutter/flutter#186373) 2026-05-11 bdero@google.com [ImpellerC] Write a depfile when --shader-bundle is in use (flutter/flutter#186341) 2026-05-11 nico.reiab@gmail.com docs: fix doubled-word typos in comments (flutter/flutter#186320) 2026-05-11 engine-flutter-autoroll@skia.org Roll Skia from 32281401997e to 91d3c1e730af (4 revisions) (flutter/flutter#186368) 2026-05-11 15619084+vashworth@users.noreply.github.com Show SwiftPM warnings right before iOS/macOS build (flutter/flutter#185984) 2026-05-11 15619084+vashworth@users.noreply.github.com Convert rebuilding-flutter-tool script to dart (flutter/flutter#185089) 2026-05-11 15619084+vashworth@users.noreply.github.com Use Xcode's LLDB (flutter/flutter#186273) 2026-05-11 mr-peipei@web.de Remove `currentMainUri` from `generateMainDartWithPluginRegistrant` (flutter/flutter#185907) 2026-05-11 engine-flutter-autoroll@skia.org Roll Skia from 2514f6b5f92b to 32281401997e (1 revision) (flutter/flutter#186349) 2026-05-11 engine-flutter-autoroll@skia.org Roll Packages from 92552b1 to 19ec8b8 (4 revisions) (flutter/flutter#186350) 2026-05-11 1063596+reidbaker@users.noreply.github.com Check for absolute paths in skills. (flutter/flutter#185632) 2026-05-11 engine-flutter-autoroll@skia.org Roll Skia from 9fb7d2814642 to 2514f6b5f92b (1 revision) (flutter/flutter#186347) 2026-05-11 engine-flutter-autoroll@skia.org Roll Skia from 8cafb209e836 to 9fb7d2814642 (4 revisions) (flutter/flutter#186335) 2026-05-10 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from sOBiPJb0xznDBZlf5... to rFhU-YPqdCRCtCz7b... (flutter/flutter#186328) 2026-05-10 engine-flutter-autoroll@skia.org Roll Skia from 05a03f99c74e to 8cafb209e836 (1 revision) (flutter/flutter#186315) 2026-05-10 bdero@google.com [Impeller] Vulkan: don't drop user-supplied viewport X, Y, and depth range (flutter/flutter#185886) 2026-05-09 mbrase@google.com Update Fuchsia tests to subpackage their child components (flutter/flutter#186259) 2026-05-09 victorsanniay@gmail.com Fix SelectableText crash with inline lambda contextMenuBuilder (flutter/flutter#184990) 2026-05-09 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from 5_TnhTsHSqtCx37o6... to sOBiPJb0xznDBZlf5... (flutter/flutter#186289) 2026-05-09 engine-flutter-autoroll@skia.org Roll Skia from dc78d4bd2efb to 05a03f99c74e (2 revisions) (flutter/flutter#186283) 2026-05-09 22373191+Hari-07@users.noreply.github.com Improve non rect platform view rendering (flutter/flutter#182662) 2026-05-08 engine-flutter-autoroll@skia.org Roll Skia from 31521f8508c7 to dc78d4bd2efb (1 revision) (flutter/flutter#186278) 2026-05-08 30870216+gaaclarke@users.noreply.github.com Moves wide_gamut_macos to arm64 (flutter/flutter#186214) 2026-05-08 98614782+auto-submit[bot]@users.noreply.github.com Reverts "[iOS] Migrate VSyncClient to a pure Obj-C implementation (#186166)" (flutter/flutter#186266) 2026-05-08 engine-flutter-autoroll@skia.org Roll Skia from a00db8749edb to 31521f8508c7 (2 revisions) (flutter/flutter#186264) 2026-05-08 97480502+b-luk@users.noreply.github.com Optimize compatible `DrawDiffRoundRect` calls to use `DrawRoundRect` (flutter/flutter#186203) 2026-05-08 bdero@google.com [triage] Add Flutter GPU as a triage team (flutter/flutter#186263) 2026-05-08 dmgr@google.com doc: Unified Check-Run User manual (flutter/flutter#186210) 2026-05-08 engine-flutter-autoroll@skia.org Roll Skia from 5f7adf4403d6 to a00db8749edb (1 revision) (flutter/flutter#186257) 2026-05-08 engine-flutter-autoroll@skia.org Roll Packages from 0411f1d to 92552b1 (1 revision) (flutter/flutter#186256) 2026-05-08 34871572+gmackall@users.noreply.github.com Add logging to figure out jvm crashes for `hot_mode_tests` (flutter/flutter#186107) 2026-05-08 engine-flutter-autoroll@skia.org Roll Skia from 926c09741ce2 to 5f7adf4403d6 (3 revisions) (flutter/flutter#186242) ...
Currently, we show SwiftPM warnings during
ensureReadyForPlatformSpecificTooling, which can happen while targeting any build (such as targeting an Android device on a macOS host). We should only show SwiftPM warnings when building for iOS or macOS, so we move the logic to be called right before the build.Fixes #185775.
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.
If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.