You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/docs/api.md
+24-19Lines changed: 24 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -340,12 +340,12 @@ await db.execute('INSERT INTO states VALUES (?)', [
340
340
341
341
## Loading Extensions
342
342
343
-
You can also load runtime extensions to an open database. First you need compile your extension to the correct architecture. Each extension has different build process, so you need to figure how to compile it yourself.
343
+
Loading runtime extensions is supported. You need compile your extension to the correct architecture. Each extension has different build process, so you need to figure how to compile it yourself.
344
344
345
-
A high-level step by step guide:
345
+
### Android
346
346
347
-
- Compile your extension as runtime loadable extension (`.so` android. A `dylib` with no extension on iOS, packed as an `.xcframework` that contains multiple `.framework` folders).
348
-
-For android you will need to generate 4 versions, each for each common Android architecture, then place them in a folder `[PROJECT ROOT]/android/app/src/main/jniLibs`. That path is special and will automatically be packaged inside your app. It will look something like this:
347
+
- Compile your extension to a dynamic library (.so)
348
+
-Compile for each common Android architecture, then place them in a folder `[PROJECT ROOT]/android/app/src/main/jniLibs`. That path is special and will automatically be packaged inside your app. It will look something like this:
349
349
350
350
```text
351
351
/android
@@ -363,24 +363,29 @@ A high-level step by step guide:
363
363
libcrsqlite.so
364
364
```
365
365
366
-
- For compiling and packaging your library on iOS I’ve wrote [how to do it here](https://ospfranco.com/generating-a-xcframework-with-dylibs-for-ios/).
367
-
- On iOS you sqlite cannot load the dylib for you automatically, you need to first call `getDylibPath` to get the runtime path of the dylib you created.
368
-
- On android this `getDylibPath` is a no-op and you just need to pass the canonical name of the library. You can then finally call the `loadExtension` function on your database:
- Follow the [Guide to generating iOS dynamic libraries](https://ospfranco.com/generating-a-xcframework-with-dylibs-for-ios/). The process is far more complex, so make sure you follow the steps in detail and create a correct `.xcframework`
369
+
- Unlike Android, iOS does not load the dylib for you automatically, you need to first call `getDylibPath` to get the runtime path of the dylib you created.
372
370
373
-
const db =open(...);
374
-
let path ="libcrsqlite"// in Android it will be the name of the .so
375
-
if (Platform.os=="ios") {
376
-
path=getDylibPath("io.vlcn.crsqlite", "crsqlite"); // You need to get the bundle name from the .framework/plist.info inside of the .xcframework you created and then the canonical name inside the same plist
377
-
}
378
-
// Extensions usually have a default entry point to be loaded, if the documentation says nothing, you should assume no entry point change
379
-
db.loadExtension(path);
371
+
### Loading the extension
380
372
381
-
// Others might need a different entry point function, you can pass it as a second argument
- On android `getDylibPath` is a no-op and you just need to pass the canonical name of the library. You can then finally call the `loadExtension` function on your database:
let path ="libcrsqlite"// in Android it will be the name of the .so
380
+
if (Platform.os=="ios") {
381
+
path=getDylibPath("io.vlcn.crsqlite", "crsqlite"); // You need to get the bundle name from the .framework/plist.info inside of the .xcframework you created and then the canonical name inside the same plist
382
+
}
383
+
// Extensions usually have a default entry point to be loaded, if the documentation says nothing, you should assume no entry point change
384
+
db.loadExtension(path);
385
+
386
+
// Others might need a different entry point function, you can pass it as a second argument
0 commit comments