`xcodebuild -list` command with Swift Packages in Xcode 16.3 leads to an INTERNAL ERROR

An internal error occurs when executing the xcodebuild -list command targeting a Swift Package. This behavior is new in Xcode 16.3 and was not present in the previous version, Xcode 16.2.

cd ~/Developer
mkdir Playground
cd Playground
swift package init
xcodebuild -list

Command line invocation:
/Applications/Xcode-16.3.0.app/Contents/Developer/usr/bin/xcodebuild -list
Resolve Package Graph
** INTERNAL ERROR: Unable to load workspace '/Users/treastrain/Developer/Playground' **
Uncaught Exception: -[Swift.__SwiftDeferredNSArray intersectsSet:]: unrecognized selector sent to instance 0x600001aab5e0
Stack:
0 __exceptionPreprocess (in CoreFoundation)
1 objc_exception_throw (in libobjc.A.dylib)
2 -[NSObject(NSObject) __retain_OA] (in CoreFoundation)
3 ___forwarding___ (in CoreFoundation)
4 _CF_forwarding_prep_0 (in CoreFoundation)
5 -[DVTCoreDevice(DVTCoreDeviceIDE) deviceSupportsBuildable:buildParameters:error:] (in IDEFoundation)
6 -[DVTCoreDevice(DVTCoreDeviceIDE) supportedArchitecturesForBuildableContext:buildParameters:error:] (in IDEFoundation)
7 _IDERunDestinationsForBuildableUsingDeviceWithBuildParameters (in IDEFoundation)
8 -[IDERunDestinationManager runDestinationsForScheme:schemeCommands:executionEnvironment:eligibleOnly:genericOnly:architectureVisibility:] (in IDEFoundation)
9 IDESchemeDetermineAvailableRunDestinations (in IDEFoundation)
10 -[IDEScheme _actuallyInvalidateAvailableRunDestinations] (in IDEFoundation)
11 addSchemeAndMakeActiveIfNecessary #1 (result:error:) in IDESwiftPackage.generateScheme(with:buildable:additionalBuildables:unsetRunnable:makeActive:orderHint:) (in IDESwiftPackageCore)
12 IDESwiftPackage.generateScheme(with:buildable:additionalBuildables:unsetRunnable:makeActive:orderHint:) (in IDESwiftPackageCore)
13 IDESwiftPackage.generateSchemes(_:isRootPackage:) (in IDESwiftPackageCore)
14 IDESwiftPackage.update(from:graphHasErrors:delegate:) (in IDESwiftPackageCore)
15 specialized IDESPMWorkspaceDelegate.rootPackagesDidUpdate(packages:graphHasErrors:modelGraphSynchronizerToken:) (in IDESwiftPackageCore)
16 closure #1 in IDESPMWorkspaceDelegate.packageGraphDidFinishAction(_:duration:result:) (in IDESwiftPackageCore)
17 partial apply for closure #1 in IDESPMWorkspaceDelegate.disableWorkspaceContentSynchronization(during:) (in IDESwiftPackageCore)
18 <deduplicated_symbol> (in DVTFoundation)
19 <deduplicated_symbol> (in DVTFoundation)
20 thunk for @escaping @callee_guaranteed () -> () (in DVTFoundation)
21 __58-[DVTModelObjectGraph performBlockCoalescingModelChanges:]_block_invoke (in DVTFoundation)
22 -[DVTModelGraphTransactionScope performTransaction:] (in DVTFoundation)
23 -[DVTModelObjectGraph performBlockCoalescingModelChanges:] (in DVTFoundation)
24 DVTModelObjectGraph.performBlockCoalescingModelChanges<A>(_:) (in DVTFoundation)
25 IDESPMWorkspaceDelegate.disableWorkspaceContentSynchronization(during:) (in IDESwiftPackageCore)
26 IDESPMWorkspaceDelegate.packageGraphDidFinishAction(_:duration:result:) (in IDESwiftPackageCore)
27 <deduplicated_symbol> (in IDESwiftPackageCore)
28 SPMWorkspace.packageGraphActionFinished(_:) (in SwiftPM)
29 closure #2 in closure #3 in SPMWorkspace.processPackageGraphActionsInBackgroundIfNeeded(canProcessPackageGraphActions:) (in SwiftPM)
30 <deduplicated_symbol> (in SwiftPM)
31 <deduplicated_symbol> (in SwiftPM)
32 <deduplicated_symbol> (in SwiftPM)
33 completeTaskWithClosure(swift::AsyncContext*, swift::SwiftError*) (in libswift_Concurrency.dylib)
zsh: abort xcodebuild -list

Environments:

% xcodebuild -version
Xcode 16.3
Build version 16E140
% swift --version
swift-driver version: 1.120.5 Apple Swift version 6.1 (swiftlang-6.1.0.110.21 clang-1700.0.13.3)
Target: arm64-apple-macosx15.0

I reported: FB17127917

I have the same problem, and I've also reported it with the Feedback Assistant. Hopefully they get around to fixing this before 16-4, since it's quite crippling.

Same issue with other xcodebuild commands for archiving or documentation generation.

Same here when targeting SPM packages instead of an xcode project or workspace.

Has anyone found a workaround?

`xcodebuild -list` command with Swift Packages in Xcode 16.3 leads to an INTERNAL ERROR
 
 
Q