watchOS
Legacy
Getting started the legacy watchOS app done in .NET MAUI.
Requirements
Follow the iOS Setup.
In order for everything to work properly devices are needed. On simulators the synchronization won’t work (and some other parts may not work as well). Also, have Bluetooth enabled if possible to ease the sync between devices and the debugging communication.
It’s recommended to read the Watch Architecture as well.
macOS Setup
Having followed the macOS setup of iOS, no additional configuration is needed, provided that when the project is opened in Xcode it will automatically have the provisioning profiles set up.
Debugging
There are two parts from where to debug:
- From Visual Studio for Mac (the iOS app)
- From Xcode (the watchOS app)
For now, there is no way to debug both apps (iOS and watchOS) at the same time given that from MAUI there is no access to debug information of the watchOS app and from Xcode an iOS stub app is installed on the iPhone to debug it. So, at the moment of debugging one needs to choose which part to have information about, therefore whether to debug from VS4M or from Xcode.
Building
Given that the MAUI iOS app needs the output of the build of Xcode, one needs to build the watchOS app from Xcode first and then from VS4M build the iOS app to run it on the device.
The output of Xcode build is stored in a location pretty similar to the next one that is configured
in the iOS.csproj:
<PropertyGroup> <WatchAppBuildPath Condition=" '$(Configuration)' == 'Debug' ">$(Home)/Library/Developer/Xcode/DerivedData/bitwarden-cbtqsueryycvflfzbsoteofskiyr/Build/Products</WatchAppBuildPath></PropertyGroup>It’s highly likely that the folder bitwarden-cbtqsueryycvflfzbsoteofskiyr won’t be the same on
every Mac. So one needs to change that part in iOS.csproj to the one created automatically by
Xcode locally.
To know exactly which is the path: Open the Project in Xcode -> Go to Product -> Show Build Folder in Finder.
This needs to be improved to have a fixed location or an easier way to get it automatically.
Synchronization
There is no way to debug the synchronization completely at the same time for the reasons aforementioned.
So one can debug one end (iOS) or the other (watchOS).
If needed to check something on both ends “at the same time” (like to check why a message is not sent/arrived), one needs to use console logging or adapt part of the MAUI code to the iOS stub app on Xcode and debug the synchronization from Xcode.