Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions packages/sqflite_tvos/CHANGELOG.md
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
## 0.0.2

* **Fix:** `getDatabasesPath()` now resolves under `Library/Caches` instead of
Documents. On a physical Apple TV the tvOS sandbox does not permit writes to
Documents, so the canonical
`openDatabase(join(await getDatabasesPath(), 'x.db'))` failed with
`SQLITE_CANTOPEN`. The simulator sandbox permits the write, which masked this.
* **Behaviour change:** apps that created a database against the simulator under
the old Documents path will resolve to a new, empty database. tvOS storage is
purgeable by platform contract — data that must survive belongs on a server or
in iCloud Key-Value Storage.

## 0.0.1

Initial release — tvOS implementation of `sqflite` for
Expand Down
12 changes: 8 additions & 4 deletions packages/sqflite_tvos/README.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,10 +23,14 @@ dependencies:
ships with tvOS.

### ⚠️ Limitations / differs from iOS
- Put the database under a `path_provider` directory (Documents /
Application Support). The tvOS sandbox is constrained and OS-managed
caches can be purged — don't store the DB in a cache/temp dir if you
need durability.
- On physical tvOS devices only `Library/Caches` and `tmp` are writable —
opening a database under Documents fails with `SQLITE_CANTOPEN` (the
simulator sandbox permits the write, masking this). The plugin's default
`getDatabasesPath()` resolves under `Library/Caches`, so the canonical
`openDatabase(join(await getDatabasesPath(), 'x.db'))` works on hardware.
Note tvOS storage is purgeable by platform contract: the OS may evict
Caches at any time, so data that must survive needs a server or iCloud
Key-Value Storage, not the local filesystem.

### ❌ Not supported on tvOS
- None for core SQLite usage.
Expand Down
2 changes: 1 addition & 1 deletion packages/sqflite_tvos/pubspec.yaml
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
name: sqflite_tvos
description: "tvOS (Apple TV) implementation of the sqflite Flutter plugin, provided by flutter-tvos."
version: 0.0.1
version: 0.0.2
homepage: https://fluttertv.dev
repository: https://github.com/fluttertv/plugins/tree/main/packages/sqflite_tvos
issue_tracker: https://github.com/fluttertv/plugins/issues
Expand Down
5 changes: 3 additions & 2 deletions packages/sqflite_tvos/tvos/Classes/SqflitePlugin.m
Original file line numberDiff line numberDiff line change
Expand Up@@ -760,10 +760,11 @@ - (void)handleOptionsCall:(FlutterMethodCall*)call result:(FlutterResult)result

//
// getDatabasesPath
// returns the Documents directory on iOS
// returns the Library/Caches directory on tvOS
// (the tvOS sandbox only allows writes to Caches and tmp)
//
- (void)handleGetDatabasesPath:(FlutterMethodCall*)call result:(FlutterResult)result {
NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSArray* paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
result(paths.firstObject);
}

Expand Down