Skip to content

PowerSyncDatabase fails on tvOS — "Could not open database ... with 6" (SQLITE_CANTOPEN) #124

@lnguyen

Description

@lnguyen

Environment

  • PowerSync Swift SDK: v1.13.0
  • tvOS: 18.x (Apple TV 4K)
  • Xcode: 16.x
  • Device: Apple TV 4K (physical device, not simulator)

Description

PowerSyncDatabase(schema:dbFilename:) throws PowerSyncException: Could not open database ... with 6 on tvOS. The same code works fine on iOS and iPadOS.

Error 6 is SQLITE_CANTOPEN.

Full error

🔴 PowerSyncException: Could not open database
/var/mobile/Containers/Data/Application//Library/Application
Support/databases/tv.db with 6

Reproduction

let db = PowerSyncDatabase(schema: mySchema, dbFilename: "tv.db")

What I've tried

  1. Manually creating the Application Support/databases/ directory before calling
    PowerSyncDatabase() — same error
  2. Setting FileProtectionType.none on the directory — same error
  3. Using a custom filename instead of the default powersync.db — same error

The directory exists and is writable (verified with FileManager.createDirectory), but the
Kotlin native SQLite layer still fails to open the file.

Suspected cause

openKotlinDBDefault() in KotlinPowerSyncDatabaseImpl.swift calls into the Kotlin/Native
PowerSyncDatabase factory. The Kotlin native SQLite binary may have a tvOS-specific issue
with file path handling or the powersync-sqlite-core.xcframework tvOS slice.

The powersync-sqlite-core.xcframework does include tvos-arm64, so the binary is present.
The issue is likely in how the Kotlin layer resolves or opens the database path on tvOS.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions