I’ve been building Apple Watch apps using Xamarin for a couple of years. I love it. I get to write apps using my favorite programming language, C#, and get all the .NET goodness that comes with it. When I’ve structured my software well I’ve re-used the core code across WearOS, Tizen, and beyond.
It isn’t always easy. That is largely because what Xamarin is doing isn’t easy. They track changes in the underlying OS and supporting technologies, and sometimes they have the rug pulled from under their feet, for example when Apple released an entirely new processor architecture with the Apple Watch 4. We are still dealing with the consequences of that one.
I’m going to share some of the things I’ve learned on the way. Some are temporary glitches, as Microsoft catch up with Apple’s changes, and some are more permanent. If you are reading this much into the future beyond December 2019, you might want to double-check the situation.
No console log messages for your Apple Watch
This one is not specific to Xamarin, but I wish I’d known about it when I started.
If you fire up the
Console app on your Mac, you’ll see log messages from your Mac, from iPhone Simulators, from real iPhones, from Apple Watch Simulators, but not from your real Apple Watch.
Perhaps this is something everyone knew about but me. I always assumed that it just wasn’t possible to receive logs from the Apple Watch, but recently I found out otherwise.
The trick is that you have to install a special profile on your watch that causes it to generate logging. You’ll need to be an Apple Developer to do this.
Go to Profiles and Logs in the Apple developer site, go to the
watchOS tab and download the sysdiagnose for watchOS profile on your iPhone, and install it. I generally download it onto my Mac and then AirDrop it to my phone.
Note that it expires after three days
The 126MB Watch app
App Store Connect Dear Developer, We identified one or more issues with a recent delivery for your app, "Kanbann" 2019.1 (2). Please correct the following issues, then upload again. ITMS-90389: Size Limit Exceeded - The size of watch application '/..WatchOSApp.app' (126MB) has exceeded the 75MB size limit. Best regards, The App Store Team
There are some NUGET packages that we install without really thinking when we start a new project. Newtonsoft Json.NET is one such package. Think again. This isn’t one you are going to want to use in Apple Watch apps.
The reason is that the Ahead Of Time Compilation (AOT) generates a massive codebase for code linked with Json.NET. To the point where I was having to use full linking just to get my app to be accepted into the store.
This makes an enormous difference to your own code/build/debug cycles, and more importantly makes the app much easier to install for end-users.
Can’t debug and run on Series 4 and 5 watches
Simply put, debugging on physical Series 4 and 5 watches isn’t possible at the moment. Frankly debugging is so horrendously slow on real devices that I only ever used it as a last resort. As of right now you can only build and run RELEASE builds on Series 4 and 5 watches. The good news is that this is likely to change soon #7012.
Can’t debug on the Simulator
Right now (December 2019) you cannot debug non-trivial apps on the Simulator either. I’ve found that as soon as I make an HttpClient call the debugger detaches. This is a known issue and the underlying cause appears to be in mono itself and a fix is on its way.
Speeding up install
Deploying your app to your Apple Watch used to be incredibly slow. I’ve found that putting your Apple Watch on the charger, and ensuring it is on the same WIFI network as your phone speeds up install-time considerably.
I generally build and install the iOS app that hosts my Apple Watch app (in Release mode), and then wait for the Watch app to be installed automatically. You can check the Apple Watch app on your iPhone to see the install progress. I occasionally have to kill that app to make it refresh the install status.
No symbols in the stack trace in App Store crashes for WatchOS apps
Although crash reports for iOS apps are symbolicated and you get to see a proper stack trace for your Xamarin iOS apps, this is not the case for Apple Watch apps at the moment.
Can’t open WatchOS storyboards in Visual Studio
There are two ways to open WatchOS Storyboards. You can use the Xamarin editor that is built in to Visual Studio, or you can editing using Xcode. As of right now, editing using Xcode seems to be the only option that is working. This is also a known issue.
Project TheWatchAppWatchOSApp is not compatible with xamarinios10 (Xamarin.iOS,Version=v1.0)
If you create a Xamarin iOS app and add a WatchOS app to it, as I just did to test something out, you’ll get an error
Project YourWatchOSApp is not compatible with xamarinios10 (Xamarin.iOS,Version=v1.0. The fix is a simple change to your iOS app’s
You can find known issues in the xamarin-macios issues page on GitHub. Despite the name it is also where you’ll find WatchOS issues.
It is very quiet, but I monitor the Xamarin Slack WatchOS channel, and will answer questions there if I can - feel free to pop in and say hello and ask and answer questions.
Despite these issues, I really enjoy building and releasing WatchOS apps using Xamarin. The issues are relatively minor, and there are almost always workaround. The Xamarin team do a stirling job.
I’ve built and released two Xamarin WatchOS apps as side-projects (Voice in a Can and Kanbann), and work as an independent consultant via my own company. I’m fully engaged until at least the middle of next year, but feel free to reach out (email@example.com).