-
-
Notifications
You must be signed in to change notification settings - Fork 44
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
[Bug]: cannot build ios loadable extension #190
Comments
You cannot dynamically load static libraries, you need to use a .framework and not a .xcframework. It's an entire topic, iOS dynamic frameworks have no extension and require to be compiled differently. You need to manually create the framework and also modify the rpath, etc etc... you will need to figure this one out yourself, but your problem has nothing to do with this library. |
Ah, I forgot I wrote about this: https://ospfranco.com/generating-a-xcframework-with-dylibs-for-ios/ But please don't create a ticket, you will need to compile it and load it yourself, nothing wrong with the library |
Sure, I know the library works perfectly and the problem is on my side |
If you want help from the community it's better if you join discord. |
Actually, it's been a while since I've taken a look at extension loading. I strongly discouraged it because it's such a complex process. I don't think you can load the dynamic frameworks on iOS without modifying the C++ code. Unlike Android they are not automacally loaded, so telling sqlite to load them for you doesn't work. Creating a static framework might load, but I'm not sure how to tell sqlite how to call the entry poiint without it calling |
Looking at your library you want to link, I don't see why you couldn't use custom tokenizer approach for it, just copy the source files and implement the correct signature. |
I've added a new method to get dylibs runtime paths on iOS, this should allow to load any library that has been properly compiled as a dylib for iOS into sqlite. Here is the PR which the updated docs: Once it's merged you should be able to load any extension. |
Thank you so much! I've tried custom tokenizers and it worked perfectly for ios. I have multiple tokenizer files and one of Right now I'm facing android build problem (no problem on ios) /* better-trigram.h */
#ifndef SQLITE_BETTER_TRIGRAM_H
#define SQLITE_BETTER_TRIGRAM_H
#ifndef SQLITE_CORE
#include "sqlite3ext.h"
#else
#include "sqlite3.h"
#endif
#ifndef SQLITE_PRIVATE
#define SQLITE_PRIVATE static
#endif
Is there any limitations on android side? |
sqlite3ext.h is not part of the source files compiled on op-sqlite, so you probably want just to define that flag, on your package.json on the "sqliteFlags" you can add any flags you want and add "-DSQLITE_CORE" or just remove that line and include "sqlite.h" |
I've tried both variants and now I'm stuck on In c_sources I have 4 files
Then if I rename file to .cpp I get another error
but my #ifdef SQLITE_CORE
SQLITE_PRIVATE int opsqlite_better_trigram_init(sqlite3 *db) {
return fts5BetterTrigramInit(db);
}
#else
SQLITE_BETTER_TRIGRAM_API int
opsqlite_better_trigram_init(sqlite3 *db, char **error,
const sqlite3_api_routines *api) {
SQLITE_EXTENSION_INIT2(api);
UNUSED_PARAM(error);
return fts5BetterTrigramInit(db);
}
#endif |
You cannot include a .c file, includes are for header .h files, the linker then takes care of linking the symbols during compilation. |
What happened?
I want to add tokenizer for my db (I know that now I can create a custom tokenizer and it works perfectly for small custom tokenizers).
I'm trying to use sqlite-better-trigram. For android I've just downloaded a
.so
files from artefacts for each architectureBut I cannot make ios work
I'm following this apple guide
.dylib
, so I've created a fork that compiles also to.a
.a
file usinglipo
to combine iossimulator architecturesxcodebuild -create-xcframework
with- library
optionbetter-trigram.xcframework
into projectI've tried different ways but overall my file structure followed the one in the guide
Is there any place I should pay attention at? Could you please share more info
op-sqlite version
10.1.0
React Native version
0.75.4
Reproducible Example
https://github.com/iliapnmrv/op-sqlite-load-extension-ios
The text was updated successfully, but these errors were encountered: