Installation
Add the Kotbase dependency to your Kotlin Multiplatform project in the commonMain source set dependencies of your shared module's build.gradle.kts:
Note
The Couchbase Lite Community Edition is free and open source. The Enterprise Edition is free for development and testing, but requires a license from Couchbase for production use. See Community vs Enterprise Edition.
Kotbase is published to Maven Central. The Couchbase Lite Enterprise Edition dependency additionally requires the Couchbase Maven repository.
Native Platforms
Native platform targets should additionally link to the Couchbase Lite dependency native binary. See Supported Platforms for more details.
Linux
Targeting JVM running on Linux or native Linux, both require a specific version of the libicu dependency. (You will see
an error such as libLiteCore.so: libicuuc.so.71: cannot open shared object file: No such file or directory indicating
the expected version.) If the required version isn't available from your distribution's package manager, you can
download it from GitHub.
Vector Search
This is an Enterprise Edition feature.
Enterprise users can also download the Couchbase Lite Vector Search extension library.
Note
To use Vector Search, you must have Couchbase Lite installed and add the Vector Search extension to your Couchbase Lite application. Vector Search is available only for 64-bit architectures and Intel processors that support the Advanced Vector Extensions 2 (AVX2) instruction set. To verify whether your device supports the AVX2 instructions set, follow these instructions.
Install Extension Libraries
Install the Vector Search library for each of the platforms your KMP project targets.
Android
kotlin {
sourceSets {
...
androidMain.dependencies {
// All standard 64-bit ARM architectures
implementation("com.couchbase.lite:couchbase-lite-android-vector-search-arm64:1.0.0")
// For x86_64 architectures
implementation("com.couchbase.lite:couchbase-lite-android-vector-search-x86_64:1.0.0")
}
}
}
Java
kotlin {
sourceSets {
...
jvmMain.dependencies {
implementation("com.couchbase.lite:couchbase-lite-java-vector-search:1.0.0")
}
}
}
iOS + macOS
- Download the binaries from here — binary download link.
- Unpack the download zip file into your Xcode project location.
- Select your target settings in Xcode and drag CouchbaseLiteVectorSearch.xcframework from your Finder to the Frameworks, Libraries, and Embedded Content section.
- Start using Couchbase Lite Vector Search with Kotbase in your project.
The Kotlin CocoaPods Gradle plugin can be used to
generate a Podspec for your project that includes the
CouchbaseLiteVectorSearch dependency. Use linkOnly = true to link the dependency without generating Kotlin
Objective-C interop:
Note
Using Swift Package Manager to install CouchbaseLiteVectorSearch requires Xcode 12+.
You can add CouchbaseLiteVectorSearch to your app using Swift Package Manger (SPM).
- Open the project to which you are going to
add CouchbaseLiteVectorSearch - Open the Project Editor to add a dependency.
- In Project Navigator:
Select your XCode project file (for example,
HostAppin the example) Xcode opens the Project Editor pane - In the Project Editor pane: Select Project > Swift Packages and [+] to add the dependency Xcode opens the Choose Package Repository dialog
- In the Choose Package Repository dialog: Enter the appropriate Couchbase Lite URL, [Next] to continue For Vector Search: https://github.com/couchbase/couchbase-lite-vector-search-spm.git
- Enter the required Version (1.0.0) and [Next] to continue
- [Finish] to close the Choose Package Repository dialog
- In Project Navigator:
Select your XCode project file (for example,
Xcode displays the name, version and URL of the added CouchbaseLiteVectorSearch package.
Linux + Mingw
Before you can use Vector Search, you must download and install the Vector Search library to the location in your project where the library can be accessed and loaded at run time. The Vector Search extension for the C platform ships with supported prebuilt libraries containing the required dependencies.
You need to set the CBLITE_VECTOR_SEARCH_LIB_PATH environment variable to the extension location instead of installing
the libraries yourself. If this environment variable is not set, then Kotbase will attempt to find the library in the
current directory.
Enable Extension
Enable the vector search extension using the following snippet:
Important
You must enable the extension before you open your database.