Xamarin Forms(iOS) with CouchBase lite AddChangeListener error

We are evaluating CouchBase as the local storage and sync solution for our cross platform framework. When I run the app on my iPhone, I get an error when the app tries to add a ChangeListener to a query:


System.ExecutionEngineException: Attempting to JIT compile method ‘(wrapper native-to-managed) Couchbase.Lite.Database:DbObserverCallback (LiteCore.Interop.C4DatabaseObserver*,void*)’ while running in aot-only mode. See https://developer.xamarin.com/guides/ios/advanced_topics/limitations/ for more information.

The code resides in the shared project(MainPage.xaml.cs) and works on Android:


var database = new Database(“FirstBucket”);
var query = QueryBuilder.Select(SelectResult.All()) .From(DataSource.Database(database)) .Where(Expression.Property(“type”).EqualTo(Expression.String(“SDK”)));

var queryToken = query.AddChangeListener((sender, args) =>
{
Console.WriteLine(args?.Results.Count());
});

Any help would be appreciated,
George

Oh dear, this is a classic case of forgotten callback attribute on a method that is called from unmanaged code. That’s a bug on the Couchbase side. I filed this for it and will push to get a fast turnaround for a release with the included fix.

Thanks!

I actually tried rolling back to the 2.0.3 release and it worked as expected. I will look for the new release and retest.

Again, thank you for the quick response,
George

Yes, the 2.0.3 release was prior to some refactoring in that area and so it will not be affected by the issue. Thanks for pointing that out, I marked the issue as a regression.