What causes the temporary loss of around 20GB of hard drive space while using XCode?
The issue is probably that the space is being taken up by swap files and possibly a hibernate sleep image. To see this do an ls -l /var/vm These files are deleted on a reboot and start increasing as you use more memory and Xcode takes a lot of memory.

You need to reduce the space used by the rest of the system. apps and data. Basically 120GB is too small unless you only use it for development and not any music or other media files. You can save a bit of disc space by removing unused applications and clearing out other languages (see other questions here) but getting a bigger or external hard disk is probably a better use of your time.

To see where the space goes see the applications in this question or from the command line du.