Repository navigation
Closed
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listplatform-iosiOS applications specificallyiOS applications specificallyplatform-macosBuilding on or for macOS specificallyBuilding on or for macOS specificallyteam-iosOwned by iOS platform teamOwned by iOS platform teamtoolAffects the "flutter" command-line tool. See also t: labels.Affects the "flutter" command-line tool. See also t: labels.triaged-iosTriaged by iOS platform teamTriaged by iOS platform team
Description
When using SwiftPM, each plugin becomes an Xcode scheme.
When running flutter clean, it iterates through the schemes and cleans each:
flutter/packages/flutter_tools/lib/src/commands/clean.dart
Lines 100 to 106 in 4bc4779
| for (final String scheme in projectInfo.schemes) { | |
| await xcodeProjectInterpreter.cleanWorkspace( | |
| xcodeWorkspace.path, | |
| scheme, | |
| verbose: _verbose, | |
| ); | |
| } |
This increases the time it takes for flutter clean to complete. The plugin schemes don't make sense to be built individually and you'd have to do it though Xcode anyways, so I think skipping them is a valid solution.
Reacted by iamgirya and Luke Memet
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listplatform-iosiOS applications specificallyiOS applications specificallyplatform-macosBuilding on or for macOS specificallyBuilding on or for macOS specificallyteam-iosOwned by iOS platform teamOwned by iOS platform teamtoolAffects the "flutter" command-line tool. See also t: labels.Affects the "flutter" command-line tool. See also t: labels.triaged-iosTriaged by iOS platform teamTriaged by iOS platform team
Activity
[-]Skip SwiftPM plugin schemes when doing `flutter clean[/-][+]Skip SwiftPM plugin schemes when doing `flutter clean`[/+]hellohuanlin commentedon Mar 26, 2026
@hellohuanlin watch out for local packages if we indeed want to skip cleaning those
vashworth commentedon Mar 31, 2026
@jmagman and I discussed this briefly and one potential solution would be to add a build flag (something like
--xcode-workspace) and only do thexcodebuild cleanif the flag is passed in.That would also fix #127708 and #173940
Another alternative may be to only clean the current scheme based on if a flavor is passed in (or default to Runner). We could also add an
--allflag or somethingvashworth commentedon Apr 28, 2026
How to get the scheme:
flutter/packages/flutter_tools/lib/src/xcode_project.dart
Lines 252 to 264 in 2ab4fab
vashworth commentedon Apr 28, 2026
Flavor docs: https://docs.flutter.dev/deployment/flavors-ios
okorohelijah commentedon Apr 30, 2026
@vashworth I suggest we clean all application/flavor schemes by default instead of introducing specific --flavor or --all flags. Plus we already have --scheme flag for developers who want to clean a specific flavor
The primary cause of the slowness during flutter clean is the sequential cleaning of individual SwiftPM plugin schemes, rather than the app's flavor schemes themselves. By simply filtering out the plugin and internal framework schemes from the loop, we can resolve the performance regression entirely while preserving the broad application cleanup developers expect from the command. wdyt?
vashworth commentedon Apr 30, 2026
That's not always the case. It is for this particular issue, but not for #127708, which was filed before SwiftPM was introduced.
okorohelijah commentedon Apr 30, 2026
@vashworth I agree. This fix directly targets #173940 and #183946, which are caused by the SwiftPM plugin schemes.
However, it doesn't necessarily address #127708. Fixing #127708 would require skipping the xcodebuild native cleanup by default, which could be a breaking change for developers who rely on it to fix corrupted native caches and it’s unclear how many developers are working exclusively on web-only platforms with no iOS devices installed so I'm not sure if the trade-off of a breaking change is worth it for that specific edge case.
Maybe a better approach for #127708 would be a separate PR that checks if a build/ios folder exists. If a developer has never built for iOS, we could safely bypass launching the xcodebuild clean step altogether. wdyt
okorohelijah commentedon Apr 30, 2026
@vashworth Plus if the ios or macos isnt being built, the time i assume should be constant maybe 3 -5 seconds which i dont think is worth the breaking change
vashworth commentedon Jun 15, 2026
Just skipping the schemes is insufficient:
https://discord.com/channels/608014603317936148/846507953959862273/1515776742982287500
Every
xcodebuildcommand triggers SwiftPM dependencies to download. We've filed an issue with Apple about this (FB22283724).flutter cleanusesxcodebuild -listto get the list of schemes:flutter/packages/flutter_tools/lib/src/commands/clean.dart
Lines 106 to 109 in 1dded18
And uses
xcodebuild cleanto actually do the clean:flutter/packages/flutter_tools/lib/src/ios/xcodeproj.dart
Lines 366 to 388 in 1dded18
As stated before, a solution would be to add a build flag (something like
--xcode-workspace) and only do thexcodebuild cleanif the flag is passed in.okorohelijah commentedon Jul 7, 2026
this is fixed by #186004
[-]Skip SwiftPM plugin schemes when doing `flutter clean`[/-][+]SwiftPM regresses `flutter clean` times[/+]vashworth commentedon Jul 8, 2026
@okorohelijah I don't think this is sufficiently fixed yet, see comment: #183946 (comment)
Bypass xcodebuild -list SwiftPM fetch during flutter clean
Make Xcode workspace cleaning optional during flutter clean (flutter#…
Revert: Make Xcode workspace cleaning optional during flutter clean (f…
Reland "Make Xcode workspace cleaning optional during flutter clean" (f…
github-actions commentedon Aug 24, 2026
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.