I'm assuming you are having at least OSX 10.7, so go ahead into the applications folder (Click on Finder icon > On the Sidebar, you'll find "Applications", click on it ), delete the "Xcode" icon. That will remove Xcode from your system completely. Restart your mac.
Now go to Xcode Releases page or Apple Developer More Downloads and download an older
version of Xcode, as needed and install. You need an Apple ID to login to that portal.
After install, you can also switch between multiple versions:
Xcode > Preferences > Locations > Command Line Tools
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…