Skip to content

Commit 3027aa1

Browse files
committed
Improve docs
1 parent 6d53789 commit 3027aa1

File tree

3 files changed

+24
-20
lines changed

3 files changed

+24
-20
lines changed

.nvmrc

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/docs/api.md

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -340,12 +340,12 @@ await db.execute('INSERT INTO states VALUES (?)', [
340340

341341
## Loading Extensions
342342

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.
344344

345-
A high-level step by step guide:
345+
### Android
346346

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:
349349

350350
```text
351351
/android
@@ -363,24 +363,29 @@ A high-level step by step guide:
363363
libcrsqlite.so
364364
```
365365

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:
366+
### iOS
369367

370-
```tsx
371-
import {open, getDylibPath} from '@op-sqlite/op-engineering';
368+
- 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.
372370

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
380372

381-
// Others might need a different entry point function, you can pass it as a second argument
382-
db.loadExtension(path, "entry_function_of_the_extension");
383-
```
373+
- 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:
374+
375+
```tsx
376+
import {open, getDylibPath} from '@op-sqlite/op-engineering';
377+
378+
const db = open(...);
379+
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
387+
db.loadExtension(path, "entry_function_of_the_extension");
388+
```
384389

385390
## Reactive Queries
386391

Binary file not shown.

0 commit comments

Comments
 (0)