Had the same issue on M1 Mac Air.
Xcode stuck and even restart did no help.
And the way it was resolved was by opening the "Activity Monitor" app and under CPU, when I sort by most used process, "installd" was the one I stop/kill and after that, the xcode app restart the download and completed successfully.