Debugging on a real Apple Watch

I updated my application for the Apple Watch, but I should have weighed it too much, and now it is definitely slowing down. I can’t understand the reasons for this slowdown, so I would like to debug the application, but I don’t know how to do it, because the application works for the simulator normally, the slowdown appears only on the device.

I tried to launch the application directly from xCode to Watch, but as soon as xCode started installing the application in Watch, it stopped execution so that I could not see what happens during operation (for example, when a certain breakpoint is started or otherwise we debug )

Does anyone have any idea what the correct way to debug on a physical Apple Watch?

PS: For example, this code:

func clearScreen() { firstPicker.setSelectedItemIndex(0) secondPicker.setSelectedItemIndex(0) defaultLabels() } func defaultLabels() { feesLabel.setText(NSLocalizedString ("FEES", comment: "Commissioni")) clearAllMenuItems() addMenuItemWithItemIcon(.Decline, title: NSLocalizedString("CAN_CEL", comment: ""), action: "clearScreen") if DefaultParameter.sharedInstance.wishMode == true { addMenuItemWithImage(UIImage(named: "will")! , title: NSLocalizedString("WILL_RECEIVE", comment: ""), action: "willWishButtonPressed") receivedLabel.setText(NSLocalizedString ("DESIRED_AMOUNT", comment: "")) } else { addMenuItemWithImage(UIImage(named: "wish")! , title: NSLocalizedString("WISH_RECEIVE", comment: ""), action: "willWishButtonPressed") receivedLabel.setText(NSLocalizedString ("RECEIVED_AMOUNT", comment: "")) } } 

it takes about 7 seconds to start ...

+6
source share
2 answers

Sounds like a familiar watchOS bug to me, so I assume you haven’t done anything wrong.

You should try to remove the watch app from your watch using the Surveillance app on your phone, and then run it again.

You will definitely need some patience, so try several times if this does not work. I had experience that it worked after several attempts.

+1
source

I do not recommend debugging the Apple Watch application by clicking the Run button in Xcode. It is very unpredictable whether this will work. This is how I debug the Apple Watch, and it works for me every time:

  • Connect iPhone to PC with Xcode
  • Launch the app on your iPhone using Xcode
  • Click the stop button in Xcode
  • On your Apple Watch, make sure that the new application update has been postponed (note that if you do not make any changes to the watch application, the new one does not seem to be copied at the moment).
  • Launch the watch app from your watch (no Xcode yet!)
  • In Xcode, click "Debug β†’ Attach to Process" and select the time zone extension process. Please note that you will see the process for both your watch application and the extension of the watch. Be sure to select a watch extension
  • In your watch, click on some element of the user interface, for example, a button.
  • Your watch application will display a screen that will be displayed in the middle of the screen. This counter continues until the watch can connect to Xcode. Sometimes it takes a few minutes (about 3 for me!). When the spinner stops, you should properly debug Xcode.

The only trick is to be patient while waiting for Xcode to connect in step 8. This is definitely slower, but gives much more performance information that runs on the simulator.

+1
source

All Articles