To avoid the two popups on first XCode launch you can install the additional components like this

sudo installer -pkg /Applications/<YOUR_XCODE>/Contents/Resources/Packages/MobileDevice.pkg -target /
sudo installer -pkg /Applications/<YOUR_XCODE>/Contents/Resources/Packages/MobileDeviceDevelopment.pkg -target /

Replace the <YOUR_XCODE> with your XCode path. The default is Xcode.app.

Check out my other post How to agree XCode license from commandline/shell for more XCode automation.