-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for Android/iOS (and react-native) #91
base: main
Are you sure you want to change the base?
Conversation
# ███████████████████████████████ ANDROID SECTION ███████████████████████████████ | ||
|
||
# Define Android NDK paths (update these to your actual NDK path) | ||
# NDK_PATH ?= /path/to/android-ndk |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ANDROID_NDK_HOME needs to be defined in case you want to compile libraries for Android.
$(CC_x86_64) $(CFLAGS) $(SQLITE_INCLUDE_PATH) $(ANDROID_CFLAGS) -shared sqlite-vec.c -o $(OUT_DIR_x86_64)/libsqlite_vec.so | ||
|
||
# Rule to compile for all Android architectures | ||
android: android_arm64-v8a android_armeabi-v7a android_x86 android_x86_64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to compile with OMIT_SIMD=1 make android
as there is a flag added above with mcpu=m1 which is not compatible by the clang compiler android uses.
mkdir -p vendor | ||
curl -o sqlite-amalgamation.zip https://www.sqlite.org/2024/sqlite-amalgamation-3450300.zip | ||
unzip -d | ||
# unzip -d | ||
unzip sqlite-amalgamation.zip |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this commands are correct, this floating unzip -d was incorrect and I had to comment it so the amalgamation was correctly downloaded.
With the current changes I got Android running on a React Native app. Tomorrow I will try to compile for iOS. |
Hey @ospfranco , thanks for your work here, would love to get this inside op-sqlite! Thanks for the insight on android/ios release assets as well. This is something I want to get into the official release process, compiled on Github Actions on every release. For android, it seems like the best approach would be new For iOS, would individual Does this approach make sense, pubishing these tarballed I think ideally most of this code will move into Github Actions, ie not in the Makefile. Ideally we can keep the |
@asg017 yeah, that's exactly what is needed. The github actions instead of the makefile sounds good to me. For generating the xcframework you only need a couple of commands. You can find them in this Rust guide I created. Again the process is similar, compile the library into
I will for now compile iOS and update the makefile so you have all the commands and then close this PR. |
I got iOS working, but it turned out more complex than I thought. I will provide more detailed instructions later, but basically, compilation is tricky and then not only an .xcframework is needed but inside dynamic |
Ok, here are more detailed compilation steps for iOS:
|
I just had a report when submitting to the app store the compiled binary does not correctly match the minOS version on the Info.plist. I might have forgotten setting the min-iOS version when compiling. I've modified the makefile to add the flag:
@asg017 just FYI when you publish your own artifacts |
The rpath was not properly set. I've written more extensively what the process is to correctly generate an Here is the full tutorial |
I want to add op-sqlite support for sqlite-vec. In order to do this I need to compile sqlite-vec to Android and iOS. Once that is done, bridging the functionality for react-native is 0 cost.
Takes care of #68 and #69.
Feedback is of course welcome.