How do i use Sqlite with unity 2021?

Hey Everyone,

Usually when i went to install Sqlite on previous unity versions i would grab files from the unityjit folder (mono.data.sqlite.dll) for proper installation but with recent unity versions 2021 onward I’ve noticed that there’s no longer a single unityjit folder but rather 3 separate unityjit-linux, unityjit-macos and unityjit-win32 folders. Does this mean if i wanted to create a project for multiple platforms i will have to add files from all 3 folders or do i just add files from win32 since its the OS I’m using for development and will automatically be compiled to work on Linux and MacOS? or perhaps i grab this file from somewhere else now?

If it is the case that i need to grab files from all 3 folders now do you know why unity made this change from a single unityjit folder out of curiosity?

thanks for taking your time to help :slight_smile:

Is this actually a Unity-maintained maintain SQLite, like installed from the package mangler?

Or is it made by someone else?

Anytime you integrate an external library it is quite common to have multiple targets, and as Unity changes over time, often you have to upgrade the libraries.

You find this file under the Unity Installation directory for example in a earlier version i would have found find it here:
C:\Program Files\Unity\Hub\Editor\2019.3.3f1\Editor\Data\MonoBleedingEdge\lib\mono\unityjit\mono.data.sqlite.dll

but unity no longer has a single unityjit folder from 2021 onward i think.

Huh… I had no idea!!

I checked the last project I used SQLite on and it was November 2017 and I got the source here:

https://github.com/codecoding/SQLite4Unity3d

That project works and uses Unity2018.4.19 but is presently frozen in time and we’re not updating it anytime soon.

Just an Update i appear to have gotten it to work by adding the mono.data.sqlite from unityjit-win32 after restarting the project but i am yet to test if this will work on a build to another OS.

This was a side effect of Mono upgrade in Unity 2021.2. Mono now uses quite a bit of CoreCLR class library code, and that code isn’t portable across all platforms. They use #ifdefs to change behaviour so we need to compile separate binaries for different platforms.

I don’t know if Mono.Data.Sqlite uses these #ifdefs or not. The safest approach would be to use all 3 and configure them properly in the inspector to target the right platform.