How to fix Xcode, when installing the required components breaks

After downloading the latest version of Xcode, I tried to open it.

Xcode greets me with Xcode component installation, stating that Xcode must install the following components before continuing.

So I clicked install and typed in the correct administrative password, but immediately after this, Xcode gives the alert " An unknown error occurred. See the [install log]( for more details."

I didn’t find the log helpful but I did find the solution online, so here it is for anyone else that goes through this:

Optional if you already have Xcode in your applications dir
* Just double click Xcode dmg file ...
* Then window will show Xcode app.
* Right Click Xcode
* Show Package contents 
* Then go to /Contents/Resources/Packages/
* Install MobileDevice.pkg ...
After installation 
* Double click on Xcode app ...
* Just see Xcode is ready ...