Command Line Tools `clean` also re-resolves Swift Package Manager dependencies

Number:rdar://FB9737989 Date Originated:2021-11-03
Status:Open Resolved:
Product:Xcode Product Version:13.1 (13A1030d)
Classification:Bug Reproducible:
Please describe the issue:

When running `xcodebuild clean`, instead of just cleaning the build outputs, Xcode also resolves the Swift Package Manager dependencies and tries to download them.

Here is an example output:

% xcodebuild clean                                                                 

Command line invocation:
    /Applications/ clean

User defaults from command line:
    IDEPackageSupportUseBuiltinSCM = YES

Resolve Package Graph

Resolved source packages:
  Starscream: @ 4.0.4
  MyPrivateLibrary: @ 1.0.1
  libPhoneNumber: @ master
  Sentry: @ 7.5.0
  Carte: @ master

note: Using new build system
note: Build preparation complete


This is a problem because the `MyPrivateLibrary` in the example above requires authentication to download. There is no reason that a `clean` task should prompt for that authentication.

Please list the steps you took to reproduce the issue:

1. Create a project
2. Add a Package Dependency that points to a private Git repository
3. Run `xcodebuild clean` from the command line

What did you expect to happen?

I expect that `clean` should not be generating new files, only removing old ones.

What actually happened?

The `clean` process is downloading and generating more files, and is prompting for input for authentication.


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!