Unable to verify xcode and simulator installation

When running npm run ios some time an error comes

$ react-native-scripts ios
Starting packager...
Starting simulator...
Unable to check Xcode version: Error: Process exited with non-zero code: 1
Failed to start simulator:
Unable to verify Xcode and Simulator installation.

The error can come if you don’t have any command line tool selected in xcode .To resolve the issue go to
Xcode->preferences -> Locations-> command line tools and select the command line tool as shown in image below.

unable to verify xcode and simulator installation.
react native error
A pat on the back !!