Working through a .Net Maui application testing Couchbase as a MongoDB replacement, everything is working great while debugging but release builds (on iOS) throw the following error:
at XXXXX.Program.Main(String[] args) in /XXXXX/Platforms/iOS/Program.cs:line 12 LiteCore (System.DllNotFoundException) at Couchbase.Lite.Logging.FileLogger.SetupDomainObjects() at Couchbase.Lite.Logging.FileLogger..ctor() at Couchbase.Lite.Logging.Log..ctor() at Couchbase.Lite.Database..cctor()
I have not tried Android yet as i am still validating this switch.
I’m not a CB Lite developer. There is a closed ticket for Maui that is marked fixed in 3.1.0. I don’t know if it is public. Log in with Atlassian account
I develop this SDK but I can’t come up with a reason why this should only happen in release mode. It means that it cannot find LiteCore.framework (which is packaged in the Couchbase.Lite.Support.iOS package in the runtimes folder).
Have you checked your csproj file to see what you have set for the linker? Release mode usually has extremely aggressive linking settings and my guess is the linker isn’t including the DLL.
An example of aggressive linking:
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<MauiLinkMode>Link All</MauiLinkMode> <!-- Link All Assemblies -->
</PropertyGroup>
That would cause issues. You should probably have this set to Link SDK assemblies or you would have to manually add the DLLs and tell them to PreserveNewest.
You can find more out from the .NET documentation:
Also since you mentioned Android - it can be even more rough than iOS due to R8 and how it tries to achieve the smallest possible build. Examples of this are here:
Usually to fight this you have to create a proguard.cfg file to tell the shinker what to keep.
All this is because again the App Stores require really small files so the tools for building releases are aggressive about throwing out code it thinks you aren’t using.
Let us know if you run into any other issues. More than happy to try and help out as much as possible. For now we’ll open up a ticket and see if we can get this fixed and a patch out. Thanks for trying out Couchbase Lite!
I don’t see anything on our end that would cause this. So far the investigation has only turned up that it’s possible for the dotnet CLI to choose the entirely wrong moniker to restore, which of course will not work. Using 8.0.401 I am able to build a mac catalyst app in release mode and run it without any problem.
I suspect the issue is with the dependencies. 3.1.x has .NET 6 across the board, while 3.2.x has .NET 6 for desktop and .NET 8 for MAUI targets. So far from what I’ve been shown, the MAUI project is mistakenly restoring .NET 6 instead of the proper .NET 8 MAUI target.
Prior to this I was was running dotnet 8.0.100 with Maui workload 8.0.82. At this point I’m recommending anyone seeing this problem to get on the latest service releases of dotnet 8 and Maui.