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)
- The migration strategy (ALTER) couldn't resolve the changes HOT 1
- Can't see the full table HOT 5
- Replace the nested `SingleChildScrollView`s in the devtools extension with `TwoDimensionalScrollView`
- SqliteException (SqliteException(1): while preparing statement, no such table: word, SQL logic error (code 1) Causing statement: SELECT * FROM "word";) HOT 4
- DriftIsolate.connect waits forever occasionally HOT 3
- [drift_flutter] driftDatabase more options HOT 2
- Setup page "Manual database setup" toggle closes when trying to copy the code
- DevTools extension replace dependency from `db_viewer` to `drift_db_viewer` HOT 2
- Error: The argument type 'String?' can't be assigned to the parameter type 'String' HOT 6
- Migrate Android app plugin loader - examples HOT 4
- Illegal cast in web wasm HOT 1
- Improve remote protocol serialization on the web
- Insert Silently HOT 4
- `schema export --dialect postgres` produces invalid SQL for DateTimeColumn and BoolColumn when defaults are specified HOT 2
- Add documentation for the Drift DevTools Extension HOT 1
- Add new option to the DevTools extension to run build_runner HOT 1
- Documentation dark mode HOT 2
- Web WASM: "RuntimeError: illegal cast at InsertStatement.insert HOT 3
- Why withDefault is no effect?is this a bug? HOT 3
- Could not build Objective-C module 'SQLite3' HOT 2
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.