Search code examples
iosios-simulatorwatchos-2watchos-simulator

Force close watchOS applications on the simulators?


When developing iOS applications, it is sometimes useful to be able to force close the app. For example: when developing features that only appear during fresh launches of the application.

Force closing is possible both on real devices and on the iOS-based simulators by following these steps:

  • Press the Home button two times quickly. You'll see small previews of your recently used apps.

  • Swipe left to find the app you want to close.

  • Swipe up on the app's preview to close it.

Several unofficial sources report that an Apple Watch application can be force closed on a real device by following these steps:

  • When the app is open, press and hold the side button until the power down menu appears.
  • When the power menu comes to the forefront, release the button.
  • Press the side button a second time and hold it until the app shuts down and you are returned to the home screen.

Question: Is it possible to force close an application on the watchOS simulators?

As far as I can tell, it's not possible to simulate a side button press on the Apple Watch simulators, so the steps listed above for a real device are not applicable. I have read Apple's simulator user guide, but the Apple Watch side button is not mentioned there. Am I missing something?


Solution

  • This is a bit convoluted but you could add a #if DEBUG ... #endif condition that gets called when tapping a button or doing a specific gesture on your debug builds. The code can just have an assertionFailure() or abort() message that force quits your app. That way you can cycle through initialisations quickly to look at what you want to look at (without the debugger attached). Just make sure you remove this once you've finished your testing cycle and take every precaution so that this does not go into production builds!