Back in 2019 while i was working on a big Xamarin.Mac based application, i needed some form of analytics and crash reporting. Since the app is cross-platform, the team decided to choose AppCenter for this. Unfortunately there was no solution for Xamarin.Mac - AppCenter was limited to macOS apps written in Objective-C / Swift.
There were plenty of Xamarin.Mac related requests and issues by the community and that’s why i decided to build the bindings myself.
TL;DR
With version 4.5.0 of the SDK, Xamarin.Mac support in AppCenter is now official - time to say goodbye to my bindings project AppCenter-XMac.
the journey of AppCenter-XMac
First i investigated an existing pull request, but unfortunately it was already outdated when i tried to build a bindings project.
I decided to start from scratch and created a new project based on the latest version of the AppCenter SDK - that’s how AppCenter-XMac was born.
My goal was to automate as much as possible, that’s why i tried Objective Sharpie
to generate bindings automatically. The tool can handle Objective-C based libraries and frameworks (also in CocoaPods form) and tries to generate ApiDefinition.cs
and StructsAndEnums.cs
files which act as a bridge between C# and Objective-C. I used the official artifcats from the AppCenter Apple SDK as inputs. Unfortunately the tool didn’t work for me - incomplete bindings or errors during code generation made me rethink my approach after a few days.
I started from scratch (again) - this time i took a look at the AppCenter dotnet SDK which already contained the bindings for iOS - these served me well during implementing the bindings manually. After i made myself familiar with the repository structure and the build process of the SDK, i started adding the macOS specific projects to the solution. I focused on AppCenter.Analytics
and AppCenter.Crashes
which turned out to be a good idea, because AppCenter.Pushes
was discontinued in 2020. The Xamarin.Mac bindings for analytics and crashes are for the most part based on the Xamarin.iOS implementation. Some types that are iOS-only needed to be changed to their macOS equivalent, which was no real challenge. More difficult was the fact that the packaging of the resulting macOS artifacts is very different compared to iOS - especially notarization and codesign was a tough one. I learned a lot about .app bundle structure and how a .framework has to be organized. After spending some days experimenting with different configurations and build scripts i had functional bindings and a demo app. The analytics data and crash reports where delivered correctly to the AppCenter web portal and with a little hack, features like non-crashing erros worked as well.
I was very happy with the result so i open-sourced the repository and created NuGet packages for the bindings. I enabled GitHub alerts for the various AppCenter repositories to get notified whenever a new version of the SDKs were released. With this approach i shipped Xamarin.Mac bindings from version 3.4.2
to 4.4.0
with usually only a few hours delay after an official SDK update. I only stopped binding new versions of the SDK when i received the following email in September 2021
it’s official
this was great news for me - i did some cleanup and opened a pull request in the official repository. Working on the PR was a charm, some cleanups and explanations were needed, but with version 4.5.0 my changes made it into the official packages. I also noticed that the web portal was updated and now supports Xamarin as an option for creating new macOS apps - hooray 🥳
time to say goodbye 👋
today i have archived the AppCenter-XMac repository, so it’s read-only now, i will also deprecate the NuGet packages, which were downloaded over 25.000 times.
I have already updated the dependencies of some of my personal projects and can report that the Xamarin.Mac support of AppCenter is working great!