4

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?

Community
  • 1
  • 1
stkent
  • 19,772
  • 14
  • 85
  • 111
  • I have not found a way to simulate the side button, but one way to force close the app is to delete it. An easier option is to just rebuild it. – Caleb Dec 18 '15 at 19:42
  • This is true, though both are pretty slow. Is there a way to rebuild without having the debugger automatically attach (for example, to test crash-reporting code)? – stkent Dec 18 '15 at 19:51
  • I do not believe there is an option for that on the watch simulator. One option that is again slower is to build it normally and immediately press the stop button and run it from the simulator. – Caleb Dec 18 '15 at 20:08

2 Answers2

3

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!

Danny Bravo
  • 4,534
  • 1
  • 25
  • 43
  • Interesting workaround, thanks! Might try hooking this into force touch everywhere so it's easily accessible from any screen. – stkent Dec 22 '15 at 20:07
0

Do you try Reboot option on tab Hardware of Apple Watch simulator. Maybe it work.

vien vu
  • 4,277
  • 2
  • 17
  • 30