Closed jgold6 closed 6 years ago
I just tried running a watch app on XCode and ran into problems. Sometimes the paired apple watch is available in the XCode device list, but sometimes it is not. Plugging in or unplugging the iPhone via USB cable changes this status i.e. if I have a message in the device list that the paired device is unavailable:
I plug or unplug the USb cable and then it shows as available:
But when I deploy, build succeeds, iPhone companion app is installed, but Apple watch app is not installed automatically. I get this dialog:
I can go into the Watch app on the phone and manually install the Watch app and then run it (so provisioning etc, should be fine) but I cannot then debug the app.
OK, so the issue was that at some point I must've clicked "Don't trust this computer" on my Apple watch when I connected my iPhone to my work computer. Opening the macOS Console app and selecting the Apple watch was the only tool that gave me an error message that led me to suspect that my watch was set to not trust my computer. To fix, I had to unpair and re-pair my apple watch to my iphone, plug it in via USB and oppen XCode and/or the Console app until I got the dialog on my watch asking to trust the computer. This time I made sure to select "Trust this computer."
Now I see the device in Visual Studio 2017 Windows, but still getting a message that "debugging is not supported in this configuration." and to start without debugging.
Starting without debugging fails first attempt due to timeout due to length of time it takes to deploy. Worked second time once watch app was already installed. I will test further in VS for Mac (just tested in VS 2017 Windows after re-pairing the watch and trusting the computer)
Now I also see the Apple Watch in the device list in VS for Mac, but only if the iPhone is plugged in via USB cable.
So this issue of the device not being in the device list was the result of my computer not being trusted by my apple watch, though the computer is trusted by my iPhone. (Dear Apple, why would a watch not trust a computer that the paired phone trusts?)
There does, however, remain the issue that I can't not launch the app for debugging in VS 2017 on Windows or in VS for Mac.
In VS for Mac, watch app gets installed, but fails to launch with error:
error MT1006: Could not install the application '/Users/jongoldberger/Downloads/WatchKitCatalog/WatchKitCatalog/bin/iPhone/Debug/device-builds/iphone10.3-11.4/WatchKitCatalog.app' on the device 'Johnny Golds iPhone X': Read Error (error: 0xe8000004).
as in this issue: https://github.com/xamarin/xamarin-macios/issues/3915
but despite what that error message says, the app does get installed to both the iPhone and the Apple Watch, but the watch app does not launch, so debugger does not connect.
Tried new cables as per suggestion in issue #3915, no change.
Tried changing the iOS Build number as per suggestion in issue #3915, no change.
Tried rebooting iPhone, Watch and Mac as per suggestion in issue #3915, and then the watch app did deploy and launch, but the debugger was not connected, i.e. breakpoints were not hit. But this seems hit or miss... deploying again after the one semi-successful attempt and I was back to the MT1006 error above.
Also deleted bin and obj folders between each of the above tests.
Debugging to a physical apple watch device does work in XCode, I could deploy to the physical watch and hit breakpoints.
Welcome to the world of the Apple Watch... 😒
First, always make sure that the phone is plugged in and the watch is on the charger.
Then execute echo 123456789 > ~/.mlaunch-verbosity
from a terminal, and try again. This will make us write much more debug information: so after executing this, please try again and attach here either deploy log (if that's what failed) or the application output (if the debugger didn't attach).
"First, always make sure that the phone is plugged in and the watch is on the charger."
If this is a requirement for debugging, I would hope it would be in the docs: https://docs.microsoft.com/en-us/xamarin/ios/watchos/deploy-test/device#testing-on-a-watch-device
However today, I am once again unable to see the Watch in the device list, whether iPhone is plugged in or not, and whether the watch is on my wrist or on the charger. (yesterday all testing was done with watch on my wrist).
I am going to try rebooting Mac and devices again to see if I can get you that log output.
After rebooting, I could see the watch in the device list with the watch on my wrist. I then moved the watch to the charger and tried deploying. The Watch app did then upload to the watch and launch successfully, but no debugging (breakpoints are not hit).
Ah, looking at the logs, I see something about wireless debugging being disabled. Since I am plugged in, I would not think that would matter, but this made me check all of the project properties for all of the apps and debugging was not enabled for the watch app. Doh. Enabling Debugging in the Watch project options watchOS Debug page allowed breakpoints to be hit. Go figure. :-) Verified working on both VS 2017 Windows and VS for Mac.
One thing though, if the watch locks itself, which it does often and there is no way I am aware of to stop the device from locking itself as there is on the iPhone, then the app won't launch and the debugger won't attach. I have to tap the watch constantly while waiting for the watch app to upload to keep the watch awake. Is there any workaround for this that you are aware of?
Also I tested again with the watch on my wrist, and was able to deploy and debug the watch app with the watch on my wrist rather than on the charger, so having the watch on the charger would seem to not be a requirement (unless there is a way to keep the watch awake when on the charger, but I can find nothing on that being possible).
So what this seems to boil down to for me is make sure the watch trusts the computer and make sure debugging is enabled for the watch app project, and keep the watch awake when deploying.
One thing though, if the watch locks itself, which it does often and there is no way I am aware of to stop the device from locking itself as there is on the iPhone, then the app won't launch and the debugger won't attach. I have to tap the watch constantly while waiting for the watch app to upload to keep the watch awake. Is there any workaround for this that you are aware of?
Disable the passcode on the watch. Then the watch will awake automatically when you launch. It might also help to adjust the timeout until the watch sleeps (the default is 15s, it can also be set to 70s in the watch's settings)
Also I tested again with the watch on my wrist, and was able to deploy and debug the watch app with the watch on my wrist rather than on the charger, so having the watch on the charger would seem to not be a requirement
It's not a requirement, but in my experience everything is much more reliable when it's on the charger.
I'm closing this, since there doesn't seem to be any bugs in the product, only a potential for better documentation (which is already reported in https://github.com/MicrosoftDocs/xamarin-docs-pr/issues/424).
Description
An Apple watch that is paired to an iPhone does not show up in the device list when the watch app is selected as the startup project, only the iPhone it is paired with and the simulators show up. As Such I am unable to deploy the watch app to a physical apple watch for debugging.
I do see the paired apple watch in Xcode Devices and Simulators window.
I am able to select the watch app as the startup project and deploy to a watch simulator for debugging (though due to timeout issues, I have to deploy a couple of times before it works).
When I select the iOS companion app as the startup project and deploy it to the iPhone, I can install and run the watch app on the paired watch, but the debugger does not get connected in this scenario. This does demonstrate that the watch is provisioned properly though.
I am using the WatchKitCatalog app to test.
Steps to Reproduce
Expected Behavior
I should see and be able to select the paired Apple watch and be able to deploy to the physical watch
Actual Behavior
Paired apple watch does not show in the device list.
Notes
When I took these screen shots, the iPhone was connected via WiFi, but I got the same results if I connected the iPhone via USB cable.
My watch's name is Jonathans Apple Watch.
Environment
Visual Studio for Mac:
Visual Studio 2017
Build Logs
N/A
Example Project (If Possible)
https://developer.xamarin.com/samples/monotouch/watchOS/WatchKitCatalog/