After the recent Visual Studio for Mac 7.4 and components update Couchbase Lite refuses to work in my solution. I tried with a new solution and added CBL 2.0-db022 and it works fine. I tried the solution in VS 2017 on Windows and it works without error in iOS. I went back to previous git commits where I know the app worked, and they don’t work anymore in VS for Mac either.
In VS for Mac when I run iOS and try to open a Database I get:
System.TypeInitializationException - System.DllNotFoundException
at (wrapper managed-to-native) LiteCore.Interop.NativeRaw.c4_getVersion()
at LiteCore.Interop.Native.c4_getVersion () [0x00000] in C:\jenkins\workspace\couchbase-lite-net\couchbase-lite-net\vendor\couchbase-lite-core\CSharp\src\LiteCore.Shared\Interop\C4Base_native.cs:116
at Couchbase.Lite.Sync.HTTPLogic.GetUserAgent () [0x00142] in C:\jenkins\workspace\couchbase-lite-net\couchbase-lite-net\src\Couchbase.Lite\Sync\HTTPLogic.cs:238
at Couchbase.Lite.Sync.HTTPLogic…cctor () [0x00000] in C:\jenkins\workspace\couchbase-lite-net\couchbase-lite-net\src\Couchbase.Lite\Sync\HTTPLogic.cs:48
With console output:
2018-03-09 12:47:40.266 MyApp.iOS[66316:3998749] Loading support items
2018-03-09 12:47:40.396 MyApp.iOS[66316:3998749] Loading libLiteCore.dylib
2018-03-09 12:47:40.419 MyApp.iOS[66316:3998749] Failed to load libLiteCore.dylib, nothing is going to work!
2018-03-09 12:47:40.419 MyApp.iOS[66316:3998749] dlerror() was empty; most likely missing architecture
Would anyone know how to get more information about why this combination fails?
The most common cause of this is having more than one project in your solution and having the projects on differing versions of Couchbase lite by mistake. In theory this shouldn’t cause so much headache but since this is a major version prerelease the api and such changes often and you can wind up with method not found errors.
I checked for different versions, and I have uninstalled and reinstalled, manually deleted packages, cleaned and restored, the NuGet packages several times to make sure they are the same and are all properly installed. And when I go back to previous commits that use (the same) older versions of Couchbase Lite (like db021) the same thing now happens.
Also a quick note that db022 is broken for actual iOS devices. Please use the simulator until db023.
If this is the simulator though then did it work with a previous version of VS?
Yes, it worked in the simulator fine until a few days ago. I believe it has something to do with the VS for Mac (and iOS and Android) update. But it only fails CBL in this solution, not in the other app where I quickly tried CBL. If I had more info about why I fails I could maybe find some workaround, or be able to file a bug report.
You could try examining the two csproj files to see if there are any differences. Also examine your .app output to make sure that the bundle contains libLiteCore.dylib and that it matches the one found in the Nuget package. The error message is saying that libLiteCore.dylib is being copied in, but it is not valid. That means that most of the functionality will be missing.
It might be easier to simply downgrade visual studio (on mac this is pretty easy, on Windows it is a nightmare so luckily this is mac in this case) and/or the xamarin frameworks to see if that makes a difference.
I checked the libLiteCore.dylib and it’s identical to the one in the NuGet package. Also:
The type initializer for ‘Couchbase.Lite.Sync.HTTPLogic’ threw an exception.
If that helps at all.
I looked at the message. That is usually the first place it fails if it has no valid libLiteCore.dylib. If it is there in the app then I don’t think VS is doing anything wrong…I can’t really reason what it could be.
After updating Visual Studio 2017 from 15.5.7 to 15.6.1 CBL now fails in the same way for iOS, unable to load libLiteCore.dylib.
I don’t understand this update. You mean it now fails in a new project?
EDIT Oh you mean it fails on Windows too now.
Were you able to try downgrading Visual Studio / Xamarin iOS on the mac machine to see if it made a difference? If it does then I will try to put together a bug report to file with Microsoft.
Do you know where I can find older version of VS for Mac? I have not found it yet.
All releases are listed at releases.xamarin.com The latest in the 15.5.x branch is 15.5.5
!! They stopped giving links to the installers there it seems. That’s news to me…and I can’t seem to log into my Xamarin account…it’s always something ><
I can get into my Xamarin account. I found the download link for the previous release iOS 184.108.40.206 (there is no previous release VS for Mac there). Will try now.
I was just typing those instructions. Good that you found them. I hate that they took away so many downlaods…only the last version is available. In this case I believe the problem would lie in Xamarin.iOS since it is responsible for building and packing.
Beware though…once you downgrade your Windows box will fail and complain about differing versions. And downgrading VS2017 on Windows is an exercise in insanity.
Also is it still true that new projects do not fail, but your project does. If so, I can try to see if the same happens for me if you share your project. If you are worried about sharing your code then you can try to remove as much as possible while still keeping the bad behavior, and you can also encrypt it using my PGP key.
I am rebuilding now with the older iOS and db022. If that works (in the Simulator), then I will update iOS again to latest 220.127.116.11 to confirm it stops working. Use db022 in a different solution and confirm that it works. Then I will try to make a cut-down version that fails.
EDIT: iOS downgrade 18.104.22.168 works with db022
EDIT: iOS upgrade to 22.214.171.124 makes db022 crash
I have removed nearly all code from the solution, but it still fails on the new iOS package (and works on the previous iOS package).
Solution file: https://we.tl/0MipPVuJzC
I am using VS for Mac and I upgraded Xamarin.iOS to 11.8 . Works just fine with DB022. I tested with our Travel Sample App . Can you give it a try.