If you run your code on the simulator and close the simulator by tapping on the window close icon then you are effectively shutting down the simulator while Xcode is attached to it. That’s why you get that error message. Rather than closing down the simulator, press the stop button in Xcode to halt the App.