xamarin / xamarin-macios

.NET for iOS, Mac Catalyst, macOS, and tvOS provide open-source bindings of the Apple SDKs for use with .NET managed languages such as C#
Other
2.48k stars 515 forks source link

Physical Apple watch does not show up in the Device list in either VS for Mac or Windows #4345

Closed jgold6 closed 6 years ago

jgold6 commented 6 years ago

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

  1. Get the watchKitCatalog app (or other Apple watch app solution) and load it into VS for Mac and/or Visual Studio 2017 Windows
  2. Select the WatchKitCatalog project as the startup project.
  3. Select Debug configuration.
  4. Click on the device drop down list and make sure you see your iPhone that is paired to your Apple watch

screen shot 2018-06-26 at 9 50 09 am

screen shot 2018-06-26 at 9 54 14 am

  1. Select the WatchApp3 project as the startup project.
  2. Click on the device drop down list.

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.

screen shot 2018-06-26 at 9 50 32 am

screen shot 2018-06-26 at 9 54 36 am

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 Enterprise 2017 for Mac ===

Version 7.5.3 (build 7)
Installation UUID: f86726f2-bd5d-4610-867e-44e82f306ca2
Runtime:
    Mono 5.10.1.57 (2017-12/ea8a24b1bbf) (64-bit)
    GTK+ 2.24.23 (Raleigh theme)
    Xamarin.Mac 4.4.1.178 (master / eeaeb7e6)

    Package version: 510010057

=== NuGet ===

Version: 4.3.1.4445

=== .NET Core ===

Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
    2.0.5
    2.0.0
    1.1.1
    1.0.4
    1.0.0
SDK: /usr/local/share/dotnet/sdk/2.1.4/Sdks
SDK Versions:
    2.1.4
    2.0.0
    1.0.1
    1.0.0-preview2-003121
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.10.1/lib/mono/msbuild/15.0/bin/Sdks

=== Xamarin.Profiler ===

Version: 1.6.2
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Xamarin.Android ===

Version: 8.3.3.2 (Visual Studio Enterprise)
Android SDK: /Users/jongoldberger/Library/Developer/Xamarin/android-sdk-macosx
    Supported Android versions:
        4.0.3 (API level 15)
        4.1   (API level 16)
        4.2   (API level 17)
        4.3   (API level 18)
        4.4   (API level 19)
        5.0   (API level 21)
        5.1   (API level 22)
        6.0   (API level 23)
        7.0   (API level 24)
        7.1   (API level 25)
        8.0   (API level 26)
        8.1   (API level 27)

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 28.0.0
SDK Build Tools Version: 27.0.3

Java SDK: /usr
java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Apple Developer Tools ===

Xcode 9.4.1 (14161)
Build 9F2000

=== Xamarin.Mac ===

Version: 4.4.1.193 (Visual Studio Enterprise)

=== Xamarin.iOS ===

Version: 11.12.0.4 (Visual Studio Enterprise)
Hash: 64fece5f
Branch: d15-7
Build date: 2018-05-29 20:00:44-0400

=== Xamarin Inspector ===

Version: 1.4.0
Hash: b3f92f9
Branch: master
Build date: Fri, 19 Jan 2018 22:00:34 GMT
Client compatibility: 1

=== Build Information ===

Release ID: 705030007
Git revision: 13cecd02aceddf29a1ed57b86f81c02994df1483
Build date: 2018-06-14 15:48:08-04
Xamarin addins: 7065de97cf22c9038fdc39dd627f2c30790fd8af
Build lane: monodevelop-lion-d15-7

=== Operating System ===

Mac OS X 10.13.5
Darwin 17.6.0 Darwin Kernel Version 17.6.0
    Tue May  8 15:22:16 PDT 2018
    root:xnu-4570.61.1~1/RELEASE_X86_64 x86_64

=== Enabled user installed addins ===

Internet of Things (IoT) development (Preview) 7.5

Visual Studio 2017

Microsoft Visual Studio Enterprise 2017 
Version 15.7.4
VisualStudio.15.Release/15.7.4+27703.2035
Microsoft .NET Framework
Version 4.7.03056

Installed Version: Enterprise

AI Tools   0.4.1.664470
This package provides options page support in Visual Studio Tools for AI.

Application Insights Tools for Visual Studio Package   8.12.10405.1
Application Insights Tools for Visual Studio

ASP.NET and Web Tools 2017   15.0.40601.0
ASP.NET and Web Tools 2017

ASP.NET Core Razor Language Services   15.7.31476
Provides languages services for ASP.NET Core Razor.

ASP.NET Web Frameworks and Tools 2017   5.2.60419.0
For additional information, visit https://www.asp.net/

Azure App Service Tools v3.0.0   15.0.40608.0
Azure App Service Tools v3.0.0

Azure Data Lake Node   1.0
This package contains the Data Lake integration nodes for Server Explorer.

Azure Data Lake Tools for Visual Studio   2.3.3000.5
Microsoft Azure Data Lake Tools for Visual Studio

Azure Functions and Web Jobs Tools   15.0.40617.0
Azure Functions and Web Jobs Tools

Azure Stream Analytics Tools for Visual Studio   2.3.3000.5
Microsoft Azure Stream Analytics Tools for Visual Studio

C# Tools   2.8.3-beta6-62923-07. Commit Hash: 7aafab561e449da50712e16c9e81742b8e7a2969
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools   1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Fabric.DiagnosticEvents   1.0
Fabric Diagnostic Events

GitHub.VisualStudio   2.5.3.2888
A Visual Studio Extension that brings the GitHub Flow into Visual Studio.

JavaScript Language Service   2.0
JavaScript Language Service

JavaScript Project System   2.0
JavaScript Project System

JavaScript UWP Project System   2.0
JavaScript UWP Project System

Merq   1.1.19-rc (a4ffc1b)
Command Bus, Event Stream and Async Manager for Visual Studio extensions.

Microsoft Azure HDInsight Azure Node   2.3.3000.5
HDInsight Node under Azure Node

Microsoft Azure Hive Query Language Service   2.3.3000.5
Language service for Hive query

Microsoft Azure Service Fabric Tools for Visual Studio   2.2
Microsoft Azure Service Fabric Tools for Visual Studio

Microsoft Azure Stream Analytics Language Service   2.3.3000.5
Language service for Azure Stream Analytics

Microsoft Azure Stream Analytics Node   1.0
Azure Stream Analytics Node under Azure Node

Microsoft Azure Tools   2.9
Microsoft Azure Tools for Microsoft Visual Studio 2017 - v2.9.10420.2

Microsoft Continuous Delivery Tools for Visual Studio   0.3
Simplifying the configuration of continuous build integration and continuous build delivery from within the Visual Studio IDE.

Microsoft JVM Debugger   1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft MI-Based Debugger   1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual Studio Tools for Containers   1.1
Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container.

Microsoft Visual Studio VC Package   1.0
Microsoft Visual Studio VC Package

Mono Debugging for Visual Studio   4.10.5-pre (ab58725)
Support for debugging Mono processes with Visual Studio.

Node.js Tools   1.4.11027.3
Adds support for developing and debugging Node.js apps in Visual Studio

NuGet Package Manager   4.6.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

ProjectServicesPackage Extension   1.0
ProjectServicesPackage Visual Studio Extension Detailed Info

Python   15.7.18156.1
Provides IntelliSense, projects, templates, debugging, interactive windows, and other support for Python developers.

Python - IronPython support   15.7.18156.1
Provides templates and integration for IronPython-based projects.

Python - Profiling support   15.7.18156.1
Profiling support for Python projects.

ResourcePackage Extension   1.0
ResourcePackage Visual Studio Extension Detailed Info

Snapshot Debugging Extension   1.0
Snapshot Debugging Visual Studio Extension Detailed Info

SQL Server Data Tools   15.1.61804.210
Microsoft SQL Server Data Tools

ToolWindowHostedEditor   1.0
Hosting json editor into a tool window

TypeScript Tools   15.7.20419.2003
TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools   2.8.3-beta6-62923-07. Commit Hash: 7aafab561e449da50712e16c9e81742b8e7a2969
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual F# Tools 10.1 for F# 4.1   15.7.0.0.  Commit Hash: 173513e369ffb7a1c4d5dccf83696d9aac2ab2d0.
Microsoft Visual F# Tools 10.1 for F# 4.1

Visual Studio Code Debug Adapter Host Package   1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

Visual Studio Tools for AI   0.4.1.664470
An integrated development environment for AI / Deep Learning application development.

Visual Studio Tools for AI: Azure Batch AI   0.4.1.664470
This package provides Azure Batch AI support in Visual Studio Tools for AI.

Visual Studio Tools for AI: Azure Cognitive Services   0.4.1.664470
This package provides Azure Cognitive Services support in Visual Studio Tools for AI.

Visual Studio Tools for AI: Azure Machine Learning   0.4.1.664470
This package provides Azure Machine Learning support in Visual Studio Tools for AI.

Visual Studio Tools for AI: Model Inference Library   0.4.1.664470
This package helps build intelligent C# applications in Visual Studio Tools for AI.

Visual Studio Tools for AI: PAI   0.4.1.664470
This package provides PAI support in Visual Studio Tools for AI.

Visual Studio Tools for AI: Remote Machine   0.4.1.664470
This package provides Remote Machine support in Visual Studio Tools for AI.

Visual Studio Tools for AI: Template   0.4.1.664470
This package is used to generate a template for creating a deep learning application in python language.

Visual Studio Tools for Apache Cordova   15.123.7408.1
Visual Studio Tools for Apache Cordova

Visual Studio Tools for Universal Windows Apps   15.0.27703.2035
The Visual Studio Tools for Universal Windows apps allow you to build a single universal app experience that can reach every device running Windows 10: phone, tablet, PC, and more. It includes the Microsoft Windows 10 Software Development Kit.

VisualStudio.Mac   1.0
Mac Extension for Visual Studio

Windows Machine Learning Generator Extension   1.0
Windows Machine Learning Visual Studio Extension Detailed Info

Xamarin   4.10.10.2 (35a01d8dc)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin Designer   4.12.1 (f3257e429)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

Xamarin.Android SDK   8.3.3.2 (HEAD/dffc59120)
Xamarin.Android Reference Assemblies and MSBuild support.

Xamarin.iOS and Xamarin.Mac SDK   11.12.0.4 (64fece5)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

Build Logs

N/A

Example Project (If Possible)

https://developer.xamarin.com/samples/monotouch/watchOS/WatchKitCatalog/

jgold6 commented 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:

screen shot 2018-06-26 at 10 54 47 am

I plug or unplug the USb cable and then it shows as available:

screen shot 2018-06-26 at 10 55 06 am

But when I deploy, build succeeds, iPhone companion app is installed, but Apple watch app is not installed automatically. I get this dialog:

screen shot 2018-06-26 at 10 52 38 am

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.

jgold6 commented 6 years ago

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)

jgold6 commented 6 years ago

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.

rolfbjarne commented 6 years ago

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).

jgold6 commented 6 years ago

"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.

jgold6 commented 6 years ago

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.

rolfbjarne commented 6 years ago

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.

rolfbjarne commented 6 years ago

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).