I solved that problem by setting the Command Line Tools in Xcode. Go to:
Xcode > Preferences > Locations
And select the command line tool from the dropdown. If you have only one version of Xcode installed, there should be only one option. If you have several versions of Xcode, then you must choose the one you need.
Update (added image for reference)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…