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

Originator:kohenkatz
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/Xcode-13.1.app/Contents/Developer/usr/bin/xcodebuild clean

User defaults from command line:
    IDEPackageSupportUseBuiltinSCM = YES

Resolve Package Graph

Resolved source packages:
  Starscream: https://github.com/daltoniam/Starscream @ 4.0.4
  MyPrivateLibrary: https://gitlab.example.com/mygroup/my-private-library.git @ 1.0.1
  libPhoneNumber: https://github.com/iziz/libPhoneNumber-iOS @ master
  Sentry: https://github.com/getsentry/sentry-cocoa.git @ 7.5.0
  Carte: https://github.com/devxoul/Carte @ master


note: Using new build system
note: Build preparation complete

** CLEAN SUCCEEDED **
```

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.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com 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!