.NET MAUI Native AOT support

I’m currently using Couchbase.Lite for an app that is being developed with .NET MAUI for iOS and Android. MAUI supports Native AOT builds for iOS and it might be coming to Android in the future.

As far as I can see, the latest Couchbase.Lite version (3.2.4) does not support Native AOT builds. At least there are dependencies listed that are explicitly not AOT ready (e.g. SimpleInjector, Newtonsoft.Json). When starting a Native AOT-built version of the app I can verify that by seeing an Exception like “SimpleInjector.VerificationOption is missing native code or metadata. This can happen for code that is not compatible with trimming or AOT.”

In the couchbase-lite-net GitHub repository, I’ve seen that there are commits pointing to an upcoming version 4 of the library. Can we expect that version to support Native AOT builds?

Thanks a lot for your help.

This motivated me to dump a lot of our third party dependencies for 4.0 which should help. I’m not exactly sure what making things Native AOT ready entails though. I tried it once and got frustrated by endless cryptic warnings and haven’t thought about it since.

Some of the restrictions are documented in the Microsoft docs. If you configure the project(s) with <IsAotCompatible>true</IsAotCompatible>, you’ll get warnings to where problems with trimming / AOT builds might arise. More info can be found at Prepare .NET libraries for trimming.

I’m happy to test the 4.0 version if it is already in a “usable” state.