This is a very frustrating issue that is on-going. I have my iPad WiFi connected and it seems to occur more often if WiFi connected rather than USB-C connected, but due to Apple only providing 1 x USB-C on the iMac. WiFi connected is the only option.
To fix this I following the following process.
In xCode Go into Window/Devices and Simulators. Select the device you are using
It will likely show that the Device is unavailable or such error message.
Power down the iPad. I found this causes the error message to go away
Power back up the iPad. Devices and Simulators will then see the device and start to prepare it for use. WAIT until it finishes preparing the device and says it is ready.
Try lunching the project to your device, it should now work ok.
Worse case, if this doesn't work, you then need to remove the device from Devices and Simulators and re-add it.
I find I need to do this about every 3-4 days or so. Quite a nuisance and something Apple needs to sort out.
Good luck.