Had the same issue. (MacBook Air late 2013, 256 GB SSD, only 40 gb of free disk space).
Solution: Remove Xcode from Applications (just go to Apps and delete it as you'd normally do with an app), and then download and install it from https://developer.apple.com/download/more/ .
Easy, quite quick and no problems.
P.S. XCode download weights 10 GB, and XCode itself weights 30 GB. So if you've already have XCode installed, then after removing it you'll have a lot of free disk space - which luckily should be no less than ~40GB that you'll need.