Skip to content

flutter clean: add --xcode-clean option to control Xcode cleaning - #181079

Closed
RusKryzhanovskiy wants to merge 1 commit into
flutter:masterfrom
RusKryzhanovskiy:fix/clean-with-swift-package-manager
Closed

RusKryzhanovskiy wants to merge 1 commit into
flutter:masterfrom
RusKryzhanovskiy:fix/clean-with-swift-package-manager

Conversation

@RusKryzhanovskiy

@RusKryzhanovskiy RusKryzhanovskiy commented Jan 16, 2026 •

Copy link
Copy Markdown

This PR adds a new --xcode-clean option to flutter clean that allows controlling how Xcode workspaces are cleaned.

Large projects using Swift Package Manager can accumulate many Xcode schemes, which causes flutter clean to run xcodebuild clean serially for every scheme, significantly increasing execution time. This change allows users to limit Xcode cleaning to application-related schemes only, or skip Xcode workspace cleaning entirely when desired.

The default behavior remains unchanged: by default, all Xcode schemes continue to be cleaned to preserve existing workflows.

New options:

  • --xcode-clean=workspace (default, current behavior): Clean all Xcode schemes.
  • --xcode-clean=app: Clean only application schemes.
  • --xcode-clean=skip: Skip Xcode workspace cleaning.

This provides a faster and more predictable cleanup experience for large SwiftPM-based workspaces while maintaining backward compatibility.

Fixes #173940, #180758

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].
  • 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 ///).
  • This PR is test-exempt.
  • All existing tests are passing.

@github-actions github-actions Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Jan 16, 2026

@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 introduces a new --xcode-clean option to the flutter clean command, providing more granular control over Xcode workspace cleaning. This is a valuable addition for large projects where cleaning all schemes can be time-consuming. The implementation is clear, using an enum for different cleaning scopes and adding comprehensive tests to validate the new functionality. The interaction with the existing --scheme option is also correctly handled. I noticed the PR description mentions that this change is test-exempt, but new tests have been added, which is great! It would be good to update the description to reflect this. My only suggestion is to add documentation for the new enum to align with the project's style guide.

@RusKryzhanovskiy
RusKryzhanovskiy force-pushed the fix/clean-with-swift-package-manager branch from d4debb7 to fe849b7 Compare January 16, 2026 16:35
@jmagman jmagman added the team-ios Owned by iOS platform team label Jan 16, 2026
@RusKryzhanovskiy
RusKryzhanovskiy force-pushed the fix/clean-with-swift-package-manager branch from fe849b7 to 7835b05 Compare January 17, 2026 01:00
@github-actions github-actions Bot removed the team-ios Owned by iOS platform team label Jan 17, 2026
@bkonyi bkonyi added the team-ios Owned by iOS platform team label Jan 19, 2026
required XcodeBasedProject xcodeProject,
}) {
final String hostProjectName = xcodeProject.hostAppProjectName;
final applicationSchemePrefix = '$hostProjectName-';

@vashworth vashworth Jan 28, 2026 •

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.

return true;
}

if (projectInfo.targets.contains(scheme)) {

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.

This will also match on non-application schemes, such as extension targets/schemes.

}

globals.printTrace('Skipping Xcode scheme "$scheme" (non-application scheme).');
return false;

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.

I think the proper way to check for "application" schemes, would be to parse the pbxproj file using plistParser.plistJsonContent and filter for PBXNativeTarget with productType = "com.apple.product-type.application"

@hellohuanlin

Copy link
Copy Markdown
Contributor

@RusKryzhanovskiy from triage: are you able to make the requested changes? thanks

@vashworth

Copy link
Copy Markdown
Contributor

from triage: We're putting this in draft to get it off our triage queue. Feel free to request review again when it's ready.

@vashworth
vashworth marked this pull request as draft February 26, 2026 22:22
@Piinks

Piinks commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

@RusKryzhanovskiy would you like to continue working on this PR?

@Piinks

Piinks commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Thank you for your contribution. I'm going to close this PR for now since there are outstanding comments, just to get this off our PR review queue. Please don't hesitate to re-open or submit a new PR if you have the time to address the review comments. Thanks!

@Piinks Piinks closed this Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

team-ios Owned by iOS 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.

Flutter: Cleaning Xcode workspace takes 2-3 minutes

6 participants