xcodebuild crash when trying to build a Swift Package

We have a script that builds several Swift Packages using xcodebuild. Since Xcode 16.3, xcodebuild crashes when invoked on a Swift Package, with the following error

xcodebuild -list
Command line invocation:
    /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -list

Resolve Package Graph
** INTERNAL ERROR: Unable to load workspace '/Users/glaurent/Developer/livesight-universalsdk/SDKs/Modules/CommonObjC' **
Uncaught Exception: -[Swift.__SwiftDeferredNSArray intersectsSet:]: unrecognized selector sent to instance 0x600002593e00
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   partial apply for closure #1 in SPMSDKPackageContainer.loadManifest() (in SwiftPM)
 31   specialized thunk for @escaping @isolated(any) @callee_guaranteed @async () -> (@out A) (in SwiftPM)
 32   partial apply for closure #1 in SPMSDKPackageContainer.loadManifest() (in SwiftPM)
 33   completeTaskWithClosure(swift::AsyncContext*, swift::SwiftError*) (in libswift_Concurrency.dylib)

This error happens regardless of the command passed to xcodebuild.

I had filed this issue as FB16928021

xcodebuild crash when trying to build a Swift Package
 
 
Q