Lost connection to the debugger IDEDebugSessionErrorDomain Code: 22

Guys I'm getting insane, I'm trying to create an app and I keep getting this error when I launch it from xcode to my iPhone 13, it happens randomly: sometimes really soon and sometimes after a while.

I don't understand if it's a problem related to my app, but I don't think so as I can open it when not connected to the debugger and it doesn't seem to crash.

Do you have any solutions?

If you create a simple test app and run it, does it work on the same device?

Same thing happening to me, but rarely. There is no crash log and it doesn't happen when not attached to XCode.

Lost connection to the debugger IDEDebugSessionErrorDomain Code: 22
 
 
Q