Why does Xcode occasionally go unresponsive?

I'm building a React Native project and it seems that at least once a week when I start my project from Visual Studio Code it gets stuck building. Then when I try and open the project in Xcode it gets stuck in the infinite loading screen like the attached image.

I end up having to delete and reinstall Xcode, which takes a good amount of time since it's such a large application. What could be going on here? Is there a way I can troubleshoot this without reinstalling Xcode every time, perhaps a way to clean the build cache without opening the project in Xcode?

Hi christiannc

The next time you encounter Xcode hanging/unresponsive, please capture a spindump [1] and a sysdiagnose. Then file a feedback report with both attached so the Xcode team can investigate.

Xcode does store cached data at ~/Library/Developer/Xcode/DerivedData. You can try deleting that directory to see if it resolves the hang. But please do file the feedback first!

[1] To capture a spindump, launch terminal and run sudo spindump. Be sure to run spindump while the hang/freeze is ongoing. The spindump will be saved at /tmp/spindump.txt.

Why does Xcode occasionally go unresponsive?
 
 
Q