diff --git a/android/CMakeLists.txt b/android/CMakeLists.txt index f2766cdc..eace805e 100644 --- a/android/CMakeLists.txt +++ b/android/CMakeLists.txt @@ -55,6 +55,12 @@ if (USE_CRSQLITE) ) endif() +if (USE_SQLITE_VEC) + add_definitions( + -DOP_SQLITE_USE_SQLITE_VEC=1 + ) +endif() + set_target_properties( ${PACKAGE_NAME} PROPERTIES CXX_STANDARD 20 diff --git a/android/build.gradle b/android/build.gradle index 59b472ef..253695a1 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -33,6 +33,7 @@ def useCRSQLite = false def performanceMode = "0" def sqliteFlags = "" def enableFTS5 = false +def useSqliteVec = false def packageJsonFile = new File("$rootDir/../package.json") def packageJson = new JsonSlurper().parseText(packageJsonFile.text) @@ -41,6 +42,7 @@ def opsqliteConfig = packageJson["op-sqlite"] if(opsqliteConfig) { useSQLCipher = opsqliteConfig["sqlcipher"] useCRSQLite = opsqliteConfig["crsqlite"] + useSqliteVec = opsqliteConfig["sqliteVec"] performanceMode = opsqliteConfig["performanceMode"] ? opsqliteConfig["performanceMode"] : "" sqliteFlags = opsqliteConfig["sqliteFlags"] ? opsqliteConfig["sqliteFlags"] : "" enableFTS5 = opsqliteConfig["fts5"] @@ -71,6 +73,10 @@ if(enableFTS5) { println "[OP-SQLITE] FTS5 enabled! 🔎" } +if(useSqliteVec) { + println "[OP-SQLITE] Sqlite Vec enabled! ↗️" +} + if (isNewArchitectureEnabled()) { apply plugin: "com.facebook.react" } @@ -138,6 +144,10 @@ android { if(enableFTS5) { cFlags += ["-DSQLITE_ENABLE_FTS4=1", "-DSQLITE_ENABLE_FTS3_PARENTHESIS=1", "-DSQLITE_ENABLE_FTS5=1"] } + if(useSqliteVec) { + cFlags += "-DOP_SQLITE_USE_SQLITE_VEC=1" + cppFlags += "-DOP_SQLITE_USE_SQLITE_VEC=1" + } cppFlags "-O2", "-fexceptions", "-frtti", "-std=c++1y", "-DONANDROID" abiFilters 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a' @@ -145,7 +155,8 @@ android { "-DSQLITE_FLAGS='$sqliteFlags'", "-DUSE_SQLCIPHER=${useSQLCipher ? 1 : 0}", "-DUSE_CRSQLITE=${useCRSQLite ? 1 : 0}", - "-DUSE_LIBSQL=${useLibsql ? 1 : 0}" + "-DUSE_LIBSQL=${useLibsql ? 1 : 0}", + "-DUSE_SQLITE_VEC=${useSqliteVec ? 1 : 0}" abiFilters (*reactNativeArchitectures()) } } diff --git a/android/cpp-adapter.cpp b/android/cpp-adapter.cpp index 1150615b..ed599ea9 100644 --- a/android/cpp-adapter.cpp +++ b/android/cpp-adapter.cpp @@ -33,7 +33,7 @@ struct OPSQLiteBridge : jni::JavaClass { std::string dbPathStr = dbPath->toStdString(); opsqlite::install(*jsiRuntime, jsCallInvoker, dbPathStr.c_str(), - "libcrsqlite"); + "libcrsqlite", "libsqlite_vec"); } static void clearStateNativeJsi(jni::alias_ref thiz) { diff --git a/android/src/main/jniLibs/arm64-v8a/libsqlite_vec.so b/android/src/main/jniLibs/arm64-v8a/libsqlite_vec.so new file mode 100755 index 00000000..2b3be9c2 Binary files /dev/null and b/android/src/main/jniLibs/arm64-v8a/libsqlite_vec.so differ diff --git a/android/src/main/jniLibs/armeabi-v7a/libsqlite_vec.so b/android/src/main/jniLibs/armeabi-v7a/libsqlite_vec.so new file mode 100755 index 00000000..2f9950fa Binary files /dev/null and b/android/src/main/jniLibs/armeabi-v7a/libsqlite_vec.so differ diff --git a/android/src/main/jniLibs/x86/libsqlite_vec.so b/android/src/main/jniLibs/x86/libsqlite_vec.so new file mode 100755 index 00000000..b7a8215e Binary files /dev/null and b/android/src/main/jniLibs/x86/libsqlite_vec.so differ diff --git a/android/src/main/jniLibs/x86_64/libsqlite_vec.so b/android/src/main/jniLibs/x86_64/libsqlite_vec.so new file mode 100755 index 00000000..0f4cf2da Binary files /dev/null and b/android/src/main/jniLibs/x86_64/libsqlite_vec.so differ diff --git a/cpp/DBHostObject.cpp b/cpp/DBHostObject.cpp index 92fe4495..e4d15ef1 100644 --- a/cpp/DBHostObject.cpp +++ b/cpp/DBHostObject.cpp @@ -171,17 +171,19 @@ DBHostObject::DBHostObject(jsi::Runtime &rt, std::string &base_path, std::shared_ptr thread_pool, std::string &db_name, std::string &path, std::string &crsqlite_path, + std::string &sqlite_vec_path, std::string &encryption_key) : base_path(base_path), jsCallInvoker(jsCallInvoker), thread_pool(thread_pool), db_name(db_name), rt(rt) { #ifdef OP_SQLITE_USE_SQLCIPHER BridgeResult result = - opsqlite_open(db_name, path, crsqlite_path, encryption_key); + opsqlite_open(db_name, path, crsqlite_path, sqlite_vec_path, encryption_key); #elif OP_SQLITE_USE_LIBSQL BridgeResult result = opsqlite_libsql_open(db_name, path, crsqlite_path); #else - BridgeResult result = opsqlite_open(db_name, path, crsqlite_path); + BridgeResult result = + opsqlite_open(db_name, path, crsqlite_path, sqlite_vec_path); #endif if (result.type == SQLiteError) { diff --git a/cpp/DBHostObject.h b/cpp/DBHostObject.h index 83822e19..de3b9d38 100644 --- a/cpp/DBHostObject.h +++ b/cpp/DBHostObject.h @@ -32,7 +32,7 @@ class JSI_EXPORT DBHostObject : public jsi::HostObject { std::shared_ptr js_call_invoker, std::shared_ptr thread_pool, std::string &db_name, std::string &path, std::string &crsqlite_path, - std::string &encryption_key); + std::string &sqlite_vec_path, std::string &encryption_key); #ifdef OP_SQLITE_USE_LIBSQL // Constructor for remoteOpen, purely for remote databases diff --git a/cpp/bindings.cpp b/cpp/bindings.cpp index ba96593e..6ba4bf9e 100644 --- a/cpp/bindings.cpp +++ b/cpp/bindings.cpp @@ -21,6 +21,7 @@ namespace jsi = facebook::jsi; std::string _base_path; std::string _crsqlite_path; +std::string _sqlite_vec_path; std::shared_ptr _invoker; std::shared_ptr thread_pool = std::make_shared(); @@ -43,10 +44,12 @@ void clearState() { } void install(jsi::Runtime &rt, std::shared_ptr invoker, - const char *base_path, const char *crsqlite_path) { + const char *base_path, const char *crsqlite_path, + const char *sqlite_vec_path) { invalidated = false; _base_path = std::string(base_path); _crsqlite_path = std::string(crsqlite_path); + _sqlite_vec_path = std::string(sqlite_vec_path); _invoker = invoker; auto open = HOSTFN("open", 1) { @@ -82,9 +85,9 @@ void install(jsi::Runtime &rt, std::shared_ptr invoker, } } - std::shared_ptr db = - std::make_shared(rt, path, invoker, thread_pool, name, - path, _crsqlite_path, encryptionKey); + std::shared_ptr db = std::make_shared( + rt, path, invoker, thread_pool, name, path, _crsqlite_path, + _sqlite_vec_path, encryptionKey); return jsi::Object::createFromHostObject(rt, db); }); diff --git a/cpp/bindings.h b/cpp/bindings.h index c205fac4..912bd47a 100644 --- a/cpp/bindings.h +++ b/cpp/bindings.h @@ -10,7 +10,8 @@ namespace jsi = facebook::jsi; namespace react = facebook::react; void install(jsi::Runtime &rt, std::shared_ptr invoker, - const char *base_path, const char *crsqlite_path); + const char *base_path, const char *crsqlite_path, + const char *sqlite_vec_path); void clearState(); } // namespace opsqlite diff --git a/cpp/bridge.cpp b/cpp/bridge.cpp index 769b1d9a..2dfb7900 100644 --- a/cpp/bridge.cpp +++ b/cpp/bridge.cpp @@ -51,12 +51,14 @@ std::string opsqlite_get_db_path(std::string const &db_name, #ifdef OP_SQLITE_USE_SQLCIPHER BridgeResult opsqlite_open(std::string const &dbName, std::string const &last_path, - std::string const &crsqlitePath, + std::string const &crsqlite_path, + std::string const &sqlite_vec_path, std::string const &encryptionKey) { #else BridgeResult opsqlite_open(std::string const &dbName, std::string const &last_path, - std::string const &crsqlitePath) { + std::string const &crsqlite_path, + std::string const &sqlite_vec_path) { #endif std::string dbPath = opsqlite_get_db_path(dbName, last_path); @@ -78,13 +80,15 @@ BridgeResult opsqlite_open(std::string const &dbName, nullptr, nullptr); #endif -#ifdef OP_SQLITE_USE_CRSQLITE + sqlite3_enable_load_extension(db, 1); + char *errMsg; - const char *crsqliteEntryPoint = "sqlite3_crsqlite_init"; - sqlite3_enable_load_extension(db, 1); +#ifdef OP_SQLITE_USE_CRSQLITE + const char *crsqliteEntryPoint = "sqlite3_crsqlite_init"; - sqlite3_load_extension(db, crsqlitePath.c_str(), crsqliteEntryPoint, &errMsg); + sqlite3_load_extension(db, crsqlite_path.c_str(), crsqliteEntryPoint, + &errMsg); if (errMsg != nullptr) { return {.type = SQLiteError, .message = errMsg}; @@ -93,6 +97,19 @@ BridgeResult opsqlite_open(std::string const &dbName, } #endif +#ifdef OP_SQLITE_USE_SQLITE_VEC + const char *vec_entry_point = "sqlite3_vec_init"; + + sqlite3_load_extension(db, sqlite_vec_path.c_str(), vec_entry_point, &errMsg); + + if (errMsg != nullptr) { + return {.type = SQLiteError, .message = errMsg}; + } else { + LOGI("Loaded sqlite-vec successfully"); + } + +#endif + return {.type = SQLiteOk, .affectedRows = 0}; } diff --git a/cpp/bridge.h b/cpp/bridge.h index 91bf0f96..87cfd86e 100644 --- a/cpp/bridge.h +++ b/cpp/bridge.h @@ -24,11 +24,13 @@ std::string opsqlite_get_db_path(std::string const &db_name, #ifdef OP_SQLITE_USE_SQLCIPHER BridgeResult opsqlite_open(std::string const &dbName, std::string const &dbPath, - std::string const &crsqlitePath, + std::string const &crsqlite_path, + std::string const &sqlite_vec_path, std::string const &encryptionKey); #else BridgeResult opsqlite_open(std::string const &dbName, std::string const &dbPath, - std::string const &crsqlitePath); + std::string const &crsqlite_path, + std::string const &sqlite_vec_path); #endif BridgeResult opsqlite_close(std::string const &dbName); diff --git a/example/ios/OPSQLiteExample.xcodeproj/project.pbxproj b/example/ios/OPSQLiteExample.xcodeproj/project.pbxproj index 887f6ecb..5461902e 100644 --- a/example/ios/OPSQLiteExample.xcodeproj/project.pbxproj +++ b/example/ios/OPSQLiteExample.xcodeproj/project.pbxproj @@ -26,11 +26,9 @@ 19F6CBCC0A4E27FBF8BF4A61 /* libPods-OPSQLiteExample-OPSQLiteExampleTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-OPSQLiteExample-OPSQLiteExampleTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 3B4392A12AC88292D35C810B /* Pods-OPSQLiteExample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OPSQLiteExample.debug.xcconfig"; path = "Target Support Files/Pods-OPSQLiteExample/Pods-OPSQLiteExample.debug.xcconfig"; sourceTree = ""; }; 5709B34CF0A7D63546082F79 /* Pods-OPSQLiteExample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OPSQLiteExample.release.xcconfig"; path = "Target Support Files/Pods-OPSQLiteExample/Pods-OPSQLiteExample.release.xcconfig"; sourceTree = ""; }; - 5B7EB9410499542E8C5724F5 /* Pods-OPSQLiteExample-OPSQLiteExampleTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OPSQLiteExample-OPSQLiteExampleTests.debug.xcconfig"; path = "Target Support Files/Pods-OPSQLiteExample-OPSQLiteExampleTests/Pods-OPSQLiteExample-OPSQLiteExampleTests.debug.xcconfig"; sourceTree = ""; }; 6EE3066EB7AAB7E17B1CAB50 /* libPods-OPSQLiteExample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-OPSQLiteExample.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = LaunchScreen.storyboard; path = OPSQLiteExample/LaunchScreen.storyboard; sourceTree = ""; }; - 89C6BE57DB24E9ADA2F236DE /* Pods-OPSQLiteExample-OPSQLiteExampleTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OPSQLiteExample-OPSQLiteExampleTests.release.xcconfig"; path = "Target Support Files/Pods-OPSQLiteExample-OPSQLiteExampleTests/Pods-OPSQLiteExample-OPSQLiteExampleTests.release.xcconfig"; sourceTree = ""; }; - 9218E48CFB1F478CAC374D68 /* sample2.sqlite */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = undefined; includeInIndex = 0; lastKnownFileType = unknown; name = sample2.sqlite; path = ../assets/sqlite/sample2.sqlite; sourceTree = ""; }; + 9218E48CFB1F478CAC374D68 /* sample2.sqlite */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = sample2.sqlite; path = ../assets/sqlite/sample2.sqlite; sourceTree = ""; }; 96FD9FD0FC4F4540AC7A9CE6 /* sample.sqlite */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = sample.sqlite; path = ../assets/sample.sqlite; sourceTree = ""; }; ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; }; /* End PBXFileReference section */ @@ -114,8 +112,6 @@ children = ( 3B4392A12AC88292D35C810B /* Pods-OPSQLiteExample.debug.xcconfig */, 5709B34CF0A7D63546082F79 /* Pods-OPSQLiteExample.release.xcconfig */, - 5B7EB9410499542E8C5724F5 /* Pods-OPSQLiteExample-OPSQLiteExampleTests.debug.xcconfig */, - 89C6BE57DB24E9ADA2F236DE /* Pods-OPSQLiteExample-OPSQLiteExampleTests.release.xcconfig */, ); path = Pods; sourceTree = ""; diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 79325530..dadf4065 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -7,7 +7,7 @@ PODS: - hermes-engine (0.74.0): - hermes-engine/Pre-built (= 0.74.0) - hermes-engine/Pre-built (0.74.0) - - op-sqlite (7.0.0): + - op-sqlite (7.3.0): - React - React-callinvoker - React-Core @@ -1358,7 +1358,7 @@ SPEC CHECKSUMS: fmt: 4c2741a687cc09f0634a2e2c72a838b99f1ff120 glog: c5d68082e772fa1c511173d6b30a9de2c05a69a2 hermes-engine: 6eae7edb2f563ee41d7c1f91f4f2e57c26d8a5c3 - op-sqlite: a8bc5990d5d1774aafbbad7da708da10e03343e3 + op-sqlite: 19633619a7badbed615a7276762510ba20a2ae71 RCT-Folly: 045d6ecaa59d826c5736dfba0b2f4083ff8d79df RCTDeprecation: 3ca8b6c36bfb302e1895b72cfe7db0de0c92cd47 RCTRequired: 9fc183af555fd0c89a366c34c1ae70b7e03b1dc5 diff --git a/example/package.json b/example/package.json index 071dd911..98d9512e 100644 --- a/example/package.json +++ b/example/package.json @@ -62,6 +62,7 @@ "performanceMode": "2", "iosSqlite": false, "fts5": true, - "libsql": false + "libsql": false, + "sqliteVec": false } } diff --git a/example/src/tests/dbsetup.spec.ts b/example/src/tests/dbsetup.spec.ts index 35319f99..ef7df6b4 100644 --- a/example/src/tests/dbsetup.spec.ts +++ b/example/src/tests/dbsetup.spec.ts @@ -19,8 +19,24 @@ const expectedVersion = isLibsql() ? '3.44.2' : '3.45.1'; +// const expectedSqliteVecVersion = 'v0.1.2-alpha.7'; + export function dbSetupTests() { describe('DB setup tests', () => { + // it('Should match the sqlite_vec version', async () => { + // let db = open({ + // name: 'versionTest.sqlite', + // }); + + // const res = db.execute('select vec_version();'); + + // expect(res.rows?._array[0]['vec_version()']).to.equal( + // expectedSqliteVecVersion, + // ); + + // db.close(); + // }); + it(`Should match the sqlite expected version ${expectedVersion}`, async () => { let db = open({ name: 'versionTest.sqlite', @@ -55,6 +71,7 @@ export function dbSetupTests() { location: ANDROID_EXTERNAL_FILES_PATH, encryptionKey: 'test', }); + androidDb.execute('DROP TABLE IF EXISTS User;'); androidDb.execute( 'CREATE TABLE User ( id INT PRIMARY KEY, name TEXT NOT NULL, age INT, networth REAL) STRICT;', diff --git a/ios/OPSQLite.mm b/ios/OPSQLite.mm index dd0d0c6c..f5621fd1 100644 --- a/ios/OPSQLite.mm +++ b/ios/OPSQLite.mm @@ -75,15 +75,25 @@ - (NSDictionary *)getConstants { documentPath = [paths objectAtIndex:0]; } - NSBundle *bundle = [NSBundle bundleWithIdentifier:@"io.vlcn.crsqlite"]; - NSString *crsqlitePath = [bundle pathForResource:@"crsqlite" ofType:@""]; + NSBundle *crsqlite_bundle = + [NSBundle bundleWithIdentifier:@"io.vlcn.crsqlite"]; + NSString *crsqlite_path = [crsqlite_bundle pathForResource:@"crsqlite" + ofType:@""]; + NSBundle *libsqlitevec_bundle = + [NSBundle bundleWithIdentifier:@"com.ospfranco.sqlitevec"]; + NSString *sqlite_vec_path = [libsqlitevec_bundle pathForResource:@"sqlitevec" + ofType:@""]; + + if (crsqlite_path == nil) { + crsqlite_path = @""; + } - if (crsqlitePath == nil) { - crsqlitePath = @""; + if (sqlite_vec_path == nil) { + sqlite_vec_path = @""; } opsqlite::install(runtime, callInvoker, [documentPath UTF8String], - [crsqlitePath UTF8String]); + [crsqlite_path UTF8String], [sqlite_vec_path UTF8String]); return @true; } diff --git a/ios/sqlitevec.xcframework/Info.plist b/ios/sqlitevec.xcframework/Info.plist new file mode 100644 index 00000000..0df1affd --- /dev/null +++ b/ios/sqlitevec.xcframework/Info.plist @@ -0,0 +1,46 @@ + + + + + AvailableLibraries + + + LibraryIdentifier + ios-arm64 + LibraryPath + sqlitevec.framework + SupportedArchitectures + + arm64 + + SupportedPlatform + ios + + + LibraryIdentifier + ios-arm64_x86_64-simulator + LibraryPath + sqlitevec.framework + SupportedArchitectures + + arm64 + x86_64 + + SupportedPlatform + ios + SupportedPlatformVariant + simulator + + + CFBundlePackageType + XFWK + XCFrameworkFormatVersion + 1.0 + CFBundleVersion + 1.0.0 + CFBundleShortVersionString + 1.0.0 + MinimumOSVersion + 8.0 + + diff --git a/ios/sqlitevec.xcframework/ios-arm64/sqlitevec.framework/Info.plist b/ios/sqlitevec.xcframework/ios-arm64/sqlitevec.framework/Info.plist new file mode 100644 index 00000000..1342836d --- /dev/null +++ b/ios/sqlitevec.xcframework/ios-arm64/sqlitevec.framework/Info.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + sqlitevec + CFBundleIdentifier + com.ospfranco.sqlitevec + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + FMWK + CFBundleSignature + ???? + CFBundleVersion + 1.0.0 + CFBundleShortVersionString + 1.0.0 + MinimumOSVersion + 8.0 + + diff --git a/ios/sqlitevec.xcframework/ios-arm64/sqlitevec.framework/sqlitevec b/ios/sqlitevec.xcframework/ios-arm64/sqlitevec.framework/sqlitevec new file mode 100755 index 00000000..9ea302de Binary files /dev/null and b/ios/sqlitevec.xcframework/ios-arm64/sqlitevec.framework/sqlitevec differ diff --git a/ios/sqlitevec.xcframework/ios-arm64_x86_64-simulator/sqlitevec.framework/Info.plist b/ios/sqlitevec.xcframework/ios-arm64_x86_64-simulator/sqlitevec.framework/Info.plist new file mode 100644 index 00000000..1342836d --- /dev/null +++ b/ios/sqlitevec.xcframework/ios-arm64_x86_64-simulator/sqlitevec.framework/Info.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + sqlitevec + CFBundleIdentifier + com.ospfranco.sqlitevec + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + FMWK + CFBundleSignature + ???? + CFBundleVersion + 1.0.0 + CFBundleShortVersionString + 1.0.0 + MinimumOSVersion + 8.0 + + diff --git a/ios/sqlitevec.xcframework/ios-arm64_x86_64-simulator/sqlitevec.framework/sqlitevec b/ios/sqlitevec.xcframework/ios-arm64_x86_64-simulator/sqlitevec.framework/sqlitevec new file mode 100755 index 00000000..8e5b8f50 Binary files /dev/null and b/ios/sqlitevec.xcframework/ios-arm64_x86_64-simulator/sqlitevec.framework/sqlitevec differ diff --git a/op-sqlite.podspec b/op-sqlite.podspec index eead372c..b5d39640 100644 --- a/op-sqlite.podspec +++ b/op-sqlite.podspec @@ -26,6 +26,7 @@ performance_mode = "0" phone_version = false sqlite_flags = "" fts5 = false +use_sqlite_vec = false if(op_sqlite_config != nil) use_sqlcipher = op_sqlite_config["sqlcipher"] == true @@ -35,6 +36,7 @@ if(op_sqlite_config != nil) phone_version = op_sqlite_config["iosSqlite"] == true sqlite_flags = op_sqlite_config["sqliteFlags"] || "" fts5 = op_sqlite_config["fts5"] == true + use_sqlite_vec = op_sqlite_config["sqliteVec"] == true end if phone_version && use_sqlcipher @@ -86,8 +88,8 @@ Pod::Spec.new do |s| end other_cflags = '-DSQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION=1' - optimizedCflags = other_cflags + '$(inherited) -DSQLITE_DQS=0 -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS=1 -DSQLITE_MAX_EXPR_DEPTH=0 -DSQLITE_OMIT_DEPRECATED=1 -DSQLITE_OMIT_PROGRESS_CALLBACK=1 -DSQLITE_OMIT_SHARED_CACHE=1 -DSQLITE_USE_ALLOCA=1' + frameworks = [] if fts5 && !phone_version then log_message.call("[OP-SQLITE] FTS5 enabled 🔎") @@ -126,7 +128,13 @@ Pod::Spec.new do |s| if use_crsqlite then log_message.call("[OP-SQLITE] using CRQSQLite 🤖") xcconfig[:GCC_PREPROCESSOR_DEFINITIONS] += " OP_SQLITE_USE_CRSQLITE=1" - s.vendored_frameworks = "ios/crsqlite.xcframework" + frameworks.push("ios/crsqlite.xcframework") + end + + if use_sqlite_vec then + log_message.call("[OP-SQLITE] using Sqlite Vec ↗️") + xcconfig[:GCC_PREPROCESSOR_DEFINITIONS] += " OP_SQLITE_USE_SQLITE_VEC=1" + frameworks.push("ios/sqlitevec.xcframework") end if use_libsql then @@ -135,9 +143,9 @@ Pod::Spec.new do |s| end xcconfig[:GCC_PREPROCESSOR_DEFINITIONS] += " OP_SQLITE_USE_LIBSQL=1" if use_crsqlite then - s.vendored_frameworks = "ios/libsql.xcframework", "ios/crsqlite.xcframework" + frameworks = ["ios/libsql.xcframework", "ios/crsqlite.xcframework"] else - s.vendored_frameworks = "ios/libsql.xcframework" + frameworks = ["ios/libsql.xcframework"] end end @@ -147,4 +155,5 @@ Pod::Spec.new do |s| end s.pod_target_xcconfig = xcconfig + s.vendored_frameworks = frameworks end diff --git a/package.json b/package.json index f74f18b7..f956d240 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "ios", "cpp", "op-sqlite.podspec", - "crsqlite.xcframework", + "ios/**.xcframework", "!lib/typescript/example", "!android/build", "!android/.cxx",