tursodatabase / libsql

libSQL is a fork of SQLite that is both Open Source, and Open Contributions.
https://turso.tech/libsql
MIT License
9.55k stars 252 forks source link

React Native support #1423

Closed ospfranco closed 3 months ago

ospfranco commented 4 months ago

Adds the necessary scripts to build the C bindings for iOS and Android which the in turn only need to be dropped into iOS/Android projects to be used via Obj-C++ or Android's JNI.

For my specific use case I use them in op-sqlite.

haaawk commented 3 months ago

Some CI checks are failing @ospfranco

ospfranco commented 3 months ago

Thanks for taking a look, however, I'm currently swamped with work and next week I'm going on vacation for several months. Feel free to take over this PR and modify it as you see fit:

After all is done and said, you only need to follow the guide I left you on notion to produce a static lib and run that against the opsqlite sample app. Once the emulator starts and everything is green you are ready to go.

P.S. if you do turn on encryption, it will require a modification to the bindings to send the encryption key from JS, so, open a PR when the time comes and I will take a look.

haaawk commented 3 months ago

Thanks for taking a look, however, I'm currently swamped with work and next week I'm going on vacation for several months. Feel free to take over this PR and modify it as you see fit:

I'm not sure I will have capacity to take this PR over. Could you please finish it to the state that's mergable. Right now multiple CI checks are failing for it so it is impossible to accept such work and integrate it into the repository.

  • The changes on build.rs are reversible

What does that mean? They are not needed? The changes that are required by Android and iOS need to be merged and if they are not compatible with other targets then they should be guarded with android or ios feature.

  • Encryption seems to be compiling sqlcipher (?) via cmake, which also includes OpenSSL flags, the problem the compilation step is hard to integrate with Android (and that's why I had to disable it). Someone else that knows the internals of libsql should give it a try.

It's ok to disable the encryption for Android and maybe iOS for now but it should be done only for that targets not for all targets which breaks them.

  • The rest seem trivial

After all is done and said, you only need to follow the guide I left you on notion to produce a static lib and run that against the opsqlite sample app. Once the emulator starts and everything is green you are ready to go.

Could you paste a link to that guide please? I haven't seen it yet.

P.S. if you do turn on encryption, it will require a modification to the bindings to send the encryption key from JS, so, open a PR when the time comes and I will take a look.

ospfranco commented 3 months ago

Leaving the guide to submitting updates to op-sqlite here for future reference:

https://ospfranco.notion.site/Libsql-4dbbf5793f654eccb9f5f68901224e97