I also had the issue on a MacBook 13" M1 and Monterey 12.6 / Xcode 14. It was a nightmare, it took me two days of countless retries!
In the console log I could see it kept failing with the following message:
[ASServiceBroker]: Connection interrupted
LaunchPad:-[LPAppManager(StoreSupport) _acceptStoreConnection:]_block_invoke app store xpc message error: Connection invalid
got event: Connection interrupted
But it was not only an issue of sleep because I was using my computer while updating. I was using VSCode at the same time, which was trying to call git, not working since packaged with Xcode which is unavailable during the update...
So I stopped using the computer and did the update with the recommendations I could see on previous posts:
- plug the computer (this time I used the Apple power adapter and not the USB C cable from my external screen)
- In battery settings --> Power Adapter --> I ticked "Prevent your Mac from automatically sleeping when the display is off"
It was long but finally it worked!
I did not try caffeinate as recommended in previous post but it could be a good alternative to altering power settings.
Previously I also tried to restart the updating process (kill it, delete Xcode, restart, clear app store cache) but apart re-downloading 12gb it did not seem to help much!
Check this out: https://github.com/RobotsAndPencils/xcodes
Downloaded and installed in 1 hr! On an M1 Mac Mini ;-)
Doh! and just now 13.2.1
I saw a hint that since xcode has a huge number of files that an active virus checker can seriously impede performance. After several failues to complete I 'paused' clamav's sentry function until the install completed. Honestly, I don't that was what did it or my constant attention over a long time.
This still happens on ventura with Xcode 14.2 it is a very annoying bug that apple.. never fix.