Clean up the InstallerSandboxes directory
I've originally added the question because I didn't have enough space to update XCode. I ended up removing then reinstalling it. But things have gotten worse, last time I uninstalled it and then I got the error that I can't reinstall it because there isn't enough space. So desperate times call for desperate measures, I have deleted the 4 directories mentioned in the question which gave me 30GB extra space. I did it with sudo an mc and mc reported it deleted around 1400000 files, it's ridiculous! So then I could reinstall XCode and it seems to be working without problems.
Edit:
To free up additional space go to About This Mac &gt; Storage &gt; Manage &gt; Developer. In there XCode Caches was 15Gb on my computer. You can delete it and the next time XCode runs it will recreate some of it but only a couple GBs.