Comments (4)
Hopefully, the upcoming native-assets feature will fix this by giving us full control over the libraries we want to link.
Since we're using dynamic libraries, I also don't think there's much of a problem on Android. sqlite3 and sqlcipher can be loaded into the same process there, we're distinguishing symbols by looking them up through the library. iOS is problematic because we're typically linking everything into one bundle, so libraries with duplicate symbol names will cause a clash.
As far as I'm aware, there really is no way to use both sqlite3 and sqlcipher in the same project on iOS. So if you have a dependency on sqlcipher, I'd drop the dependency on sqlite3_flutter_libs
and just have drift use sqlcipher instead (since sqlcipher works without encryption as well).
from drift.
Original comment mentions a temporary solution, which can be untimatively resolved by dart-lang/sdk#50565
Original comment
But the `drift` itself depends on the `sqlite3`. Even though it is not linking any libraries to drift, it might be very misleading because:sqlite3.so != package:sqlite3
sqlite3.so == package:sqlite3_flutter_libs
One of possible long-term solutions to prevent any issues with the setup is to split drift
in multiple packages.
drift
containing the runtime classes andDelegatedDatabase
- no
sqlite3
reference
- no
drift_sqlite3
containing native/wasm implementation- depends on
sqlite3
- depends on
sqlite3_flutter_libs
- contains
Sqlite3DriftDatabase
(DelegatedDatabase
impl)
- depends on
drift_sqflite_sqlcipher
containing Method Channel implementation for SQLCipher- depends on
sqflite_sqlcipher
- contains
SqfliteSqlCipherDriftDatabase
(DelegatedDatabase
impl) (before:EncryptedExecutor
) - in doc specifies to override
sqflite
for 3rd party (likeflutter_cache_manager
) with link to source [*]
- depends on
- [FUTURE]
drift_sqlcipher
containing FFI implementation for SQLCipher- depends on
sqlcipher_flutter_libs
- contains
SqlCipherDriftDatabase
(DelegatedDatabase
impl) - in doc specifies to override
sqflite
for 3rd party (likeflutter_cache_manager
) with link to source [*]
- depends on
[*] Dependency override for 3rd party packages dependent on sqflite
dependency_overrides:
...
sqflite:
git:
url: https://www.github.com/davidmartos96/sqflite_sqlcipher.git
ref: fmdb_override
path: sqflite
For usage without encryption:
dependencies:
drift: any
drift_sqlite3: any
For usage with encryption:
dependency_overrides:
sqflite:
git:
url: https://www.github.com/davidmartos96/sqflite_sqlcipher.git
ref: fmdb_override
path: sqflite
dependencies:
drift: any
drift_sqflite_sqlcipher: any
# OR
# drift_sqlcipher: any
As a result, the usage will be more straightforward and will not require any additional setup. And this will eliminate almost all problems that might be cause by the database linking. Do you see any caveats with this approach?
P.S. With this approach, drift_dev
depending on sqlite3
will still be a bit misleading 😅
P.P.S. One of examples in the repo might be outdated. drift#examples/encryption
example, that just overrides linux/windows libaries, needs to be updated with a remark that on IOS that does not work.
P.P.P.S. Do I understand correctly that if I modify EncryptedExecutor
to accept nullable password, and open non-encrypted database with null
password, drift will still be able to read/write the database normally, right? If yes, then the suggested approach, in case if someone decided to switch to encrypted database, will just need to change drift_sqlite3
to drift_sqlcipher
.
from drift.
I'd drop the dependency on
sqlite3_flutter_libs
and just have drift use sqlcipher instead
@simolus3 Do I have to simply remove sqlite3_flutter_libs
or replace it with sqlcipher_flutter_libs
?
To use SQLCipher only:
- replace
sqlite3_flutter_libs
withsqlcipher_flutter_libs
- make sure that
sqflite
override andsqlcipher_flutter_libs
are using the sameSQLCipher
version- For example,
SQLCipher 4.5.4
is used by:- current sqflite_sqlcipher
fmdb_override
branch (6be83a5) sqlcipher_flutter_libs: 0.5.7
- current sqflite_sqlcipher
- For example,
- override
sqlite3.open
as described in this example
main.dart in Flutter app:
import 'package:sqlcipher_flutter_libs/sqlcipher_flutter_libs.dart';
import 'package:sqlite3/open.dart';
void main() {
// No need to override IOS
// because `sqlite3.framework` is already replaced with SQLCipher implementation
open.overrideFor(OperatingSystem.android, openCipherOnAndroid);
WidgetsFlutterBinding.ensureInitialized();
// ...
runApp(...);
}
pubspec.yaml in Flutter app:
dependency_overrides:
sqflite: # fmdb_override
dependencies:
drift:
sqlite3:
sqlcipher_flutter_libs:
pubspec.yaml in Plugin:
dependencies:
drift:
sqlite3:
sqlcipher_flutter_libs:
encrypted_drift: # extras/encryption
from drift.
Hopefully, the upcoming native-assets feature will fix this by giving us full control over the libraries we want to link.
dart-lang/sdk#50565 would be really a game-changer.
Monitoring it now 👀
from drift.
Related Issues (20)
- Why withDefault is no effect?is this a bug? HOT 3
- Could not build Objective-C module 'SQLite3' HOT 2
- `distinct()` with `omit` parameter. HOT 3
- WEB: Failed to register a service worker: The script has an unsupported MIME type ('text/plain'). HOT 14
- ? Depreciate `drift_sqflite` and publish Migrations Guide ? HOT 2
- Nullable Columns Without Defaults use `Value` HOT 3
- Hot Reload & SchemaVersion HOT 2
- Generated Tests HOT 5
- is drift support 【HAVING COUNT...】? HOT 1
- SQL Parsing Error with Special Characters (e.g., $ , ''',#) in Query HOT 4
- Exported schema do not contain column `check()` constraints HOT 2
- database.g.dart have syntax error
- There is an application that may have multiple locations where SQL is written simultaneously. However, this has caused the user interface to become stuck every time. HOT 18
- Error G0A556F40: The return type of the method '_$Database.allTables' is wrong HOT 2
- Can not build with sqlcipher_flutter_libs HOT 1
- Error if use sqlcipher_flutter_libs HOT 1
- Circular error when deserializing drift modules HOT 1
- Follow-up on SQL Parsing Error Fix (#3218) HOT 3
- Compiler Errors in Generated File Due to Missing Imports for Custom Row Classes HOT 1
- suddenly getting 59 lint notifications without preforming any changes to the database class HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from drift.