If you search this issue in Google you will get a number of different solutions.I have tried the solution below in a step by step manner and resolved the issue.
Xcode cannot run using the selected device
How to fix some common Xcode Errors
You need to Delete app from device
Disconnect device from the system
Restart iPhone or iPad device and Xcode
You should clear derived data content
Clean your project (cmd + shift + k)
Build your project Again
Some key concepts for an iPhone Developer to learn as a fresher.