diff --git a/android/CMakeLists.txt b/android/CMakeLists.txt
index da632394..dcd69ca0 100644
--- a/android/CMakeLists.txt
+++ b/android/CMakeLists.txt
@@ -5,10 +5,16 @@ set (PACKAGE_NAME "op-sqlite")
include_directories(
../cpp
- ../cpp/sqlcipher
- ../cpp/libsql
)
+if (USE_SQLCIPHER)
+ include_directories(../cpp/sqlcipher)
+endif()
+
+if (USE_LIBSQL)
+ include_directories(src/main/jniLibs/include)
+endif()
+
add_definitions(
${SQLITE_FLAGS}
)
@@ -45,7 +51,7 @@ elseif (USE_LIBSQL)
-DOP_SQLITE_USE_LIBSQL=1
)
else()
- target_sources(${PACKAGE_NAME} PRIVATE ../cpp/sqlite3.h ../cpp/sqlite3.c ../cpp/bridge.cpp ../cpp/bridge.h)
+ target_sources(${PACKAGE_NAME} PRIVATE ../cpp/sqlite3.c ../cpp/bridge.cpp)
endif()
if (USE_CRSQLITE)
@@ -64,7 +70,7 @@ find_package(ReactAndroid REQUIRED CONFIG)
find_package(fbjni REQUIRED CONFIG)
find_library(LOG_LIB log)
-# Add user defined files
+# Add user defined files (the generated tokenizers)
if (USER_DEFINED_SOURCE_FILES)
target_sources(${PACKAGE_NAME} PRIVATE ${USER_DEFINED_SOURCE_FILES})
@@ -81,17 +87,20 @@ if (USE_SQLCIPHER)
openssl::crypto
)
elseif (USE_LIBSQL)
- cmake_path(SET LIBSQL ${CMAKE_CURRENT_SOURCE_DIR}/jniLibs/${ANDROID_ABI}/libsql_experimental.a NORMALIZE)
- add_library(libsql STATIC IMPORTED)
- set_target_properties(libsql PROPERTIES IMPORTED_LOCATION ${LIBSQL})
+ cmake_path(SET LIBSQL_PATH ${CMAKE_CURRENT_SOURCE_DIR}/src/main/jniLibs/${ANDROID_ABI}/libsql_experimental.so NORMALIZE)
+ add_library(libsql_experimental SHARED IMPORTED)
+ set_target_properties(libsql_experimental PROPERTIES
+ IMPORTED_LOCATION ${LIBSQL_PATH}
+ IMPORTED_NO_SONAME TRUE
+ )
target_link_libraries(
${PACKAGE_NAME}
+ libsql_experimental
${LOG_LIB}
ReactAndroid::reactnative
ReactAndroid::jsi
fbjni::fbjni
- libsql
)
else ()
target_link_libraries(
diff --git a/android/build.gradle b/android/build.gradle
index 7df016db..3e92544a 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -104,7 +104,11 @@ if(useSqliteVec) {
println "[OP-SQLITE] Sqlite-vec enabled"
}
-if (!tokenizers.isEmpty()) {
+if(!tokenizers.isEmpty()) {
+ if(useLibsql) {
+ throw new GradleException("[OP-SQLITE] Error: libsql does not support tokenizers. Please disable tokenizers or do not enable libsql.")
+ }
+
println "[OP-SQLITE] Tokenizers enabled. Detected tokenizers: " + tokenizers
}
@@ -117,6 +121,8 @@ android {
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
+ buildConfigField "boolean", "USE_LIBSQL", "${useLibsql}"
+
externalNativeBuild {
cmake {
if(useSQLCipher) {
@@ -216,6 +222,9 @@ android {
]
jniLibs {
srcDirs = []
+ if (useLibsql) {
+ srcDirs += 'src/main/jniLibs'
+ }
if (useCRSQLite) {
srcDirs += 'src/main/libcrsqlite'
}
diff --git a/android/jniLibs/arm64-v8a/libsql_experimental.a b/android/jniLibs/arm64-v8a/libsql_experimental.a
deleted file mode 100644
index 157daea9..00000000
Binary files a/android/jniLibs/arm64-v8a/libsql_experimental.a and /dev/null differ
diff --git a/android/jniLibs/armeabi-v7a/libsql_experimental.a b/android/jniLibs/armeabi-v7a/libsql_experimental.a
deleted file mode 100644
index 0f31cc42..00000000
Binary files a/android/jniLibs/armeabi-v7a/libsql_experimental.a and /dev/null differ
diff --git a/android/jniLibs/x86/libsql_experimental.a b/android/jniLibs/x86/libsql_experimental.a
deleted file mode 100644
index 066561e7..00000000
Binary files a/android/jniLibs/x86/libsql_experimental.a and /dev/null differ
diff --git a/android/jniLibs/x86_64/libsql_experimental.a b/android/jniLibs/x86_64/libsql_experimental.a
deleted file mode 100644
index 8625b4f8..00000000
Binary files a/android/jniLibs/x86_64/libsql_experimental.a and /dev/null differ
diff --git a/android/src/main/java/com/op/sqlite/OPSQLiteModule.kt b/android/src/main/java/com/op/sqlite/OPSQLiteModule.kt
index 49a01b9f..8d341b72 100644
--- a/android/src/main/java/com/op/sqlite/OPSQLiteModule.kt
+++ b/android/src/main/java/com/op/sqlite/OPSQLiteModule.kt
@@ -110,6 +110,9 @@ internal class OPSQLiteModule(context: ReactApplicationContext?) : ReactContextB
companion object {
init {
+ if (BuildConfig.USE_LIBSQL) {
+ System.loadLibrary("sql_experimental")
+ }
System.loadLibrary("op-sqlite")
}
diff --git a/android/src/main/jniLibs/arm64-v8a/libsql_experimental.so b/android/src/main/jniLibs/arm64-v8a/libsql_experimental.so
new file mode 100755
index 00000000..96e501fc
Binary files /dev/null and b/android/src/main/jniLibs/arm64-v8a/libsql_experimental.so differ
diff --git a/android/src/main/jniLibs/armeabi-v7a/libsql_experimental.so b/android/src/main/jniLibs/armeabi-v7a/libsql_experimental.so
new file mode 100755
index 00000000..1863f840
Binary files /dev/null and b/android/src/main/jniLibs/armeabi-v7a/libsql_experimental.so differ
diff --git a/cpp/libsql/libsql.h b/android/src/main/jniLibs/include/libsql.h
similarity index 94%
rename from cpp/libsql/libsql.h
rename to android/src/main/jniLibs/include/libsql.h
index b14c7b5a..5a43eaac 100644
--- a/cpp/libsql/libsql.h
+++ b/android/src/main/jniLibs/include/libsql.h
@@ -93,6 +93,12 @@ int libsql_open_file(const char *url, libsql_database_t *out_db, const char **ou
int libsql_open_remote(const char *url, const char *auth_token, libsql_database_t *out_db, const char **out_err_msg);
+int libsql_open_remote_with_remote_encryption(const char *url,
+ const char *auth_token,
+ const char *remote_encryption_key,
+ libsql_database_t *out_db,
+ const char **out_err_msg);
+
int libsql_open_remote_with_webpki(const char *url,
const char *auth_token,
libsql_database_t *out_db,
diff --git a/android/src/main/jniLibs/x86/libsql_experimental.so b/android/src/main/jniLibs/x86/libsql_experimental.so
new file mode 100755
index 00000000..fb08a3db
Binary files /dev/null and b/android/src/main/jniLibs/x86/libsql_experimental.so differ
diff --git a/android/src/main/jniLibs/x86_64/libsql_experimental.so b/android/src/main/jniLibs/x86_64/libsql_experimental.so
new file mode 100755
index 00000000..ba23e4f1
Binary files /dev/null and b/android/src/main/jniLibs/x86_64/libsql_experimental.so differ
diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock
index 3a2f5ec1..8cec003a 100644
--- a/example/ios/Podfile.lock
+++ b/example/ios/Podfile.lock
@@ -2027,7 +2027,7 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
FBLazyVector: 2e5b5553df729e080483373db6f045201ff4e6db
hermes-engine: 273e30e7fb618279934b0b95ffab60ecedb7acf5
- op-sqlite: 4651f571998e9739cd4fe16f033bd8a159279da6
+ op-sqlite: 137a619945c21df76fda2744680061b8f3251839
OpServer: 9b3ebdeeb095950e760e3c39853cd06849421b35
RCTDeprecation: c6b36da89aa26090c8684d29c2868dcca2cd4554
RCTRequired: 1413a0844770d00fa1f1bb2da4680adfa8698065
diff --git a/example/package.json b/example/package.json
index f9ec23a3..4440166c 100644
--- a/example/package.json
+++ b/example/package.json
@@ -45,7 +45,7 @@
"node": ">=18"
},
"op-sqlite": {
- "libsql": false,
+ "libsql": true,
"sqlcipher": false,
"iosSqlite": false,
"fts5": true,
diff --git a/example/src/tests/dbsetup.ts b/example/src/tests/dbsetup.ts
index f12088e6..15695dfa 100644
--- a/example/src/tests/dbsetup.ts
+++ b/example/src/tests/dbsetup.ts
@@ -288,15 +288,3 @@ if (isSQLCipher()) {
db.close();
});
}
-
-// This test wasn't really failing, but the module was not being properly
-// invalidated/re-created on a hot reload
-// Check opsqlite::invalidated
-// itOnly('Can execute async pragma', async () => {
-// const db = open({
-// name: 'pragma.sqlite',
-// });
-
-// const result = await db.execute('select sqlite_version() as version');
-// expect(result).toBe('1.52');
-// });
diff --git a/ios/libsql.xcframework/ios-arm64/libsql_experimental.a b/ios/libsql.xcframework/ios-arm64/libsql_experimental.a
deleted file mode 100644
index 12665a63..00000000
Binary files a/ios/libsql.xcframework/ios-arm64/libsql_experimental.a and /dev/null differ
diff --git a/ios/libsql.xcframework/ios-arm64_x86_64-simulator/libsql_experimental.a b/ios/libsql.xcframework/ios-arm64_x86_64-simulator/libsql_experimental.a
deleted file mode 100644
index 32164c48..00000000
Binary files a/ios/libsql.xcframework/ios-arm64_x86_64-simulator/libsql_experimental.a and /dev/null differ
diff --git a/ios/libsql.xcframework/Info.plist b/ios/libsql_experimental.xcframework/Info.plist
similarity index 68%
rename from ios/libsql.xcframework/Info.plist
rename to ios/libsql_experimental.xcframework/Info.plist
index fad6ff8c..94cbfdcc 100644
--- a/ios/libsql.xcframework/Info.plist
+++ b/ios/libsql_experimental.xcframework/Info.plist
@@ -5,14 +5,10 @@
AvailableLibraries
- BinaryPath
- libsql_experimental.a
- HeadersPath
- Headers
LibraryIdentifier
ios-arm64
LibraryPath
- libsql_experimental.a
+ libsql_experimental.framework
SupportedArchitectures
arm64
@@ -21,18 +17,13 @@
ios
- BinaryPath
- libsql_experimental.a
- HeadersPath
- Headers
LibraryIdentifier
- ios-arm64_x86_64-simulator
+ ios-arm64-simulator
LibraryPath
- libsql_experimental.a
+ libsql_experimental.framework
SupportedArchitectures
arm64
- x86_64
SupportedPlatform
ios
@@ -44,5 +35,9 @@
XFWK
XCFrameworkFormatVersion
1.0
+ CFBundleVersion
+ 1.0.0
+ CFBundleShortVersionString
+ 1.0.0
-
+
\ No newline at end of file
diff --git a/ios/libsql.xcframework/ios-arm64/Headers/libsql.h b/ios/libsql_experimental.xcframework/ios-arm64-simulator/libsql_experimental.framework/Headers/libsql.h
similarity index 94%
rename from ios/libsql.xcframework/ios-arm64/Headers/libsql.h
rename to ios/libsql_experimental.xcframework/ios-arm64-simulator/libsql_experimental.framework/Headers/libsql.h
index b14c7b5a..5a43eaac 100644
--- a/ios/libsql.xcframework/ios-arm64/Headers/libsql.h
+++ b/ios/libsql_experimental.xcframework/ios-arm64-simulator/libsql_experimental.framework/Headers/libsql.h
@@ -93,6 +93,12 @@ int libsql_open_file(const char *url, libsql_database_t *out_db, const char **ou
int libsql_open_remote(const char *url, const char *auth_token, libsql_database_t *out_db, const char **out_err_msg);
+int libsql_open_remote_with_remote_encryption(const char *url,
+ const char *auth_token,
+ const char *remote_encryption_key,
+ libsql_database_t *out_db,
+ const char **out_err_msg);
+
int libsql_open_remote_with_webpki(const char *url,
const char *auth_token,
libsql_database_t *out_db,
diff --git a/ios/libsql_experimental.xcframework/ios-arm64-simulator/libsql_experimental.framework/Info.plist b/ios/libsql_experimental.xcframework/ios-arm64-simulator/libsql_experimental.framework/Info.plist
new file mode 100644
index 00000000..46a43f7e
--- /dev/null
+++ b/ios/libsql_experimental.xcframework/ios-arm64-simulator/libsql_experimental.framework/Info.plist
@@ -0,0 +1,24 @@
+
+
+
+
+ CFBundleDevelopmentRegion
+ en
+ CFBundleExecutable
+ libsql_experimental
+ CFBundleIdentifier
+ com.turso.libsql-experimental
+ CFBundleInfoDictionaryVersion
+ 6.0
+ CFBundlePackageType
+ FMWK
+ CFBundleSignature
+ ????
+ CFBundleVersion
+ 1.0.0
+ CFBundleShortVersionString
+ 1.0.0
+ MinimumOSVersion
+ 13.0
+
+
\ No newline at end of file
diff --git a/ios/libsql_experimental.xcframework/ios-arm64-simulator/libsql_experimental.framework/_CodeSignature/CodeResources b/ios/libsql_experimental.xcframework/ios-arm64-simulator/libsql_experimental.framework/_CodeSignature/CodeResources
new file mode 100644
index 00000000..09f767de
--- /dev/null
+++ b/ios/libsql_experimental.xcframework/ios-arm64-simulator/libsql_experimental.framework/_CodeSignature/CodeResources
@@ -0,0 +1,101 @@
+
+
+
+
+ files
+
+ Info.plist
+
+ y2tAwL6cV6izJFZOQN6d4oaV1Wk=
+
+
+ files2
+
+ rules
+
+ ^.*
+
+ ^.*\.lproj/
+
+ optional
+
+ weight
+ 1000
+
+ ^.*\.lproj/locversion.plist$
+
+ omit
+
+ weight
+ 1100
+
+ ^Base\.lproj/
+
+ weight
+ 1010
+
+ ^version.plist$
+
+
+ rules2
+
+ .*\.dSYM($|/)
+
+ weight
+ 11
+
+ ^(.*/)?\.DS_Store$
+
+ omit
+
+ weight
+ 2000
+
+ ^.*
+
+ ^.*\.lproj/
+
+ optional
+
+ weight
+ 1000
+
+ ^.*\.lproj/locversion.plist$
+
+ omit
+
+ weight
+ 1100
+
+ ^Base\.lproj/
+
+ weight
+ 1010
+
+ ^Info\.plist$
+
+ omit
+
+ weight
+ 20
+
+ ^PkgInfo$
+
+ omit
+
+ weight
+ 20
+
+ ^embedded\.provisionprofile$
+
+ weight
+ 20
+
+ ^version\.plist$
+
+ weight
+ 20
+
+
+
+
diff --git a/ios/libsql_experimental.xcframework/ios-arm64-simulator/libsql_experimental.framework/libsql_experimental b/ios/libsql_experimental.xcframework/ios-arm64-simulator/libsql_experimental.framework/libsql_experimental
new file mode 100755
index 00000000..cde5f7dd
Binary files /dev/null and b/ios/libsql_experimental.xcframework/ios-arm64-simulator/libsql_experimental.framework/libsql_experimental differ
diff --git a/ios/libsql.xcframework/ios-arm64_x86_64-simulator/Headers/libsql.h b/ios/libsql_experimental.xcframework/ios-arm64/libsql_experimental.framework/Headers/libsql.h
similarity index 94%
rename from ios/libsql.xcframework/ios-arm64_x86_64-simulator/Headers/libsql.h
rename to ios/libsql_experimental.xcframework/ios-arm64/libsql_experimental.framework/Headers/libsql.h
index b14c7b5a..5a43eaac 100644
--- a/ios/libsql.xcframework/ios-arm64_x86_64-simulator/Headers/libsql.h
+++ b/ios/libsql_experimental.xcframework/ios-arm64/libsql_experimental.framework/Headers/libsql.h
@@ -93,6 +93,12 @@ int libsql_open_file(const char *url, libsql_database_t *out_db, const char **ou
int libsql_open_remote(const char *url, const char *auth_token, libsql_database_t *out_db, const char **out_err_msg);
+int libsql_open_remote_with_remote_encryption(const char *url,
+ const char *auth_token,
+ const char *remote_encryption_key,
+ libsql_database_t *out_db,
+ const char **out_err_msg);
+
int libsql_open_remote_with_webpki(const char *url,
const char *auth_token,
libsql_database_t *out_db,
diff --git a/ios/libsql_experimental.xcframework/ios-arm64/libsql_experimental.framework/Info.plist b/ios/libsql_experimental.xcframework/ios-arm64/libsql_experimental.framework/Info.plist
new file mode 100644
index 00000000..46a43f7e
--- /dev/null
+++ b/ios/libsql_experimental.xcframework/ios-arm64/libsql_experimental.framework/Info.plist
@@ -0,0 +1,24 @@
+
+
+
+
+ CFBundleDevelopmentRegion
+ en
+ CFBundleExecutable
+ libsql_experimental
+ CFBundleIdentifier
+ com.turso.libsql-experimental
+ CFBundleInfoDictionaryVersion
+ 6.0
+ CFBundlePackageType
+ FMWK
+ CFBundleSignature
+ ????
+ CFBundleVersion
+ 1.0.0
+ CFBundleShortVersionString
+ 1.0.0
+ MinimumOSVersion
+ 13.0
+
+
\ No newline at end of file
diff --git a/ios/libsql_experimental.xcframework/ios-arm64/libsql_experimental.framework/_CodeSignature/CodeResources b/ios/libsql_experimental.xcframework/ios-arm64/libsql_experimental.framework/_CodeSignature/CodeResources
new file mode 100644
index 00000000..09f767de
--- /dev/null
+++ b/ios/libsql_experimental.xcframework/ios-arm64/libsql_experimental.framework/_CodeSignature/CodeResources
@@ -0,0 +1,101 @@
+
+
+
+
+ files
+
+ Info.plist
+
+ y2tAwL6cV6izJFZOQN6d4oaV1Wk=
+
+
+ files2
+
+ rules
+
+ ^.*
+
+ ^.*\.lproj/
+
+ optional
+
+ weight
+ 1000
+
+ ^.*\.lproj/locversion.plist$
+
+ omit
+
+ weight
+ 1100
+
+ ^Base\.lproj/
+
+ weight
+ 1010
+
+ ^version.plist$
+
+
+ rules2
+
+ .*\.dSYM($|/)
+
+ weight
+ 11
+
+ ^(.*/)?\.DS_Store$
+
+ omit
+
+ weight
+ 2000
+
+ ^.*
+
+ ^.*\.lproj/
+
+ optional
+
+ weight
+ 1000
+
+ ^.*\.lproj/locversion.plist$
+
+ omit
+
+ weight
+ 1100
+
+ ^Base\.lproj/
+
+ weight
+ 1010
+
+ ^Info\.plist$
+
+ omit
+
+ weight
+ 20
+
+ ^PkgInfo$
+
+ omit
+
+ weight
+ 20
+
+ ^embedded\.provisionprofile$
+
+ weight
+ 20
+
+ ^version\.plist$
+
+ weight
+ 20
+
+
+
+
diff --git a/ios/libsql_experimental.xcframework/ios-arm64/libsql_experimental.framework/libsql_experimental b/ios/libsql_experimental.xcframework/ios-arm64/libsql_experimental.framework/libsql_experimental
new file mode 100755
index 00000000..a2986ebb
Binary files /dev/null and b/ios/libsql_experimental.xcframework/ios-arm64/libsql_experimental.framework/libsql_experimental differ
diff --git a/op-sqlite.podspec b/op-sqlite.podspec
index fdd38a68..e717811f 100644
--- a/op-sqlite.podspec
+++ b/op-sqlite.podspec
@@ -130,7 +130,7 @@ Pod::Spec.new do |s|
xcconfig[:GCC_PREPROCESSOR_DEFINITIONS] += " OP_SQLITE_USE_SQLCIPHER=1 HAVE_FULLFSYNC=1 SQLITE_HAS_CODEC SQLITE_TEMP_STORE=3 SQLITE_EXTRA_INIT=sqlcipher_extra_init SQLITE_EXTRA_SHUTDOWN=sqlcipher_extra_shutdown"
s.dependency "OpenSSL-Universal"
elsif use_libsql then
- log_message.call("[OP-SQLITE] using libsql. Please contact turso (via Discord) for libsql issues")
+ log_message.call("[OP-SQLITE] ⚠️ Using libsql. If you have libsql questions please ask in the Turso Discord server.")
exclude_files += ["cpp/sqlite3.c", "cpp/sqlite3.h", "cpp/sqlcipher/sqlite3.c", "cpp/sqlcipher/sqlite3.h", "cpp/bridge.h", "cpp/bridge.cpp"]
else
log_message.call("[OP-SQLITE] using pure SQLite")
@@ -185,9 +185,9 @@ Pod::Spec.new do |s|
if use_libsql then
xcconfig[:GCC_PREPROCESSOR_DEFINITIONS] += " OP_SQLITE_USE_LIBSQL=1"
if use_crsqlite then
- frameworks = ["ios/libsql.xcframework", "ios/crsqlite.xcframework"]
+ frameworks = ["ios/libsql_experimental.xcframework", "ios/crsqlite.xcframework"]
else
- frameworks = ["ios/libsql.xcframework"]
+ frameworks = ["ios/libsql_experimental.xcframework"]
end
end
diff --git a/scripts/test-ios.sh b/scripts/test-ios.sh
index ace996ff..61f85905 100755
--- a/scripts/test-ios.sh
+++ b/scripts/test-ios.sh
@@ -10,4 +10,16 @@ sleep 5
cd ..
-node ./scripts/poll-in-app-server.js
\ No newline at end of file
+node ./scripts/poll-in-app-server.js
+
+if [ $? -ne 0 ]; then
+ echo "poll-in-app-server failed, printing device logs..."
+ DEVICE_ID=$(xcrun simctl list devices booted | grep -m1 Booted | awk -F '[()]' '{print $2}')
+ if [ -n "$DEVICE_ID" ]; then
+ xcrun simctl spawn "$DEVICE_ID" log show --style syslog --predicate 'process == "OPSQLiteExample"' --info --debug --last 10m
+ else
+ echo "No booted simulator device found."
+ fi
+fi
+
+
diff --git a/scripts/turnOnLibsql.js b/scripts/turnOnLibsql.js
index 9b125f88..d2692b2b 100644
--- a/scripts/turnOnLibsql.js
+++ b/scripts/turnOnLibsql.js
@@ -6,6 +6,8 @@ const packageJson = JSON.parse(fs.readFileSync('./example/package.json'));
// Modify the op-sqlite.sqlcipher key to true
packageJson['op-sqlite']['libsql'] = true;
packageJson['op-sqlite']['sqlcipher'] = false;
+packageJson['op-sqlite']['ioSqlite'] = false;
+delete packageJson['op-sqlite']['tokenizers'];
// Save the updated package.json file
fs.writeFileSync(