This error occurred when I used the Iphone for debugging.I've tried restarting the Iphone and mac,but it hasn't worked.

way1: Restart XCode :) way2: Enable background app fetch on iPhone (disable low-power mode)
I had to click the small yellow hammer on the top bar on xcode and set it to the new build setting (rather than legacy build)
What worked for me was these steps:
At this point I just waited a few seconds and then the error went away, before also completing the build and running the app successfully on the device.