How can I avoid the situation in xcode running app

2019-09-09 09:07发布

问题:

When I run the app in xcode,it always show the case as below and my app on iphone simulator was stopped in a view,I can do nothing.Can any one tell me how to avoid this case appearing,thanks.

here are the code in warning.

   (void)processCollision:(UIImageView *)bricks{
score+=10;
scoreLabel.text =[NSString stringWithFormat:@"%05d" , score];
if (ballMovement.x>0&& bricks.frame.origin.x-ball.center.x<=4) {
    ballMovement.x=-ballMovement.x;
}else if(ballMovement.x<0&&ball.center.x-(bricks.frame.origin.x+bricks.frame.size.width)<=4){
    ballMovement.x=-ballMovement.x;
}

if (ballMovement.y>0&&bricks.frame.origin.y-ball.center.y<=4) {
    ballMovement.y=-ballMovement.y;
}else if(ballMovement.y<0&&ball.center.y-(bricks.frame.origin.y+bricks.frame.size.height)<=4){
    ballMovement.y=-ballMovement.y;
    bricks.alpha-=0.1;
}

}

回答1:

What does it say in the console?

EDIT:

The Error:

Couldn't register stream.IVBricker with the bootstrap server. Error: unknown error code. This generally means that another instance of this process was already running or is hung in the debugger.(lldb) –

This can be fixed by restarting your computer.



回答2:

I can't help with the initial bug, but the aftermath, where you get the "This generally means that another instance of this process was already running or is hung in the debugger.", message and Xcode won't debug anymore, is easily fixed.

This error occurs because the debugging monitor process on your device has become disconnected and no new debug processes can be started for that particular app while the debugging monitor is still present.

The solution is NOT to restart your computer, but to restart your DEVICE.

Hold down power and home buttons at the same time. Ignore everything that happens until you see the Apple Logo, then let go.

You will find Xcode will now debug correctly again.

No need to shut down Xcode, restart your computer or anything else.



回答3:

Add an exception breakpoint to break into debugger when your code throws exception which is causing this problem. That way you can find and correct that code.

In the breakpoint pane (left in your screenshot, the second last icon button) you can add break point by clicking plus icon to left-bottom. Once breakpoint is added, run your program from debugger.