#5480·flet

[Bug] iOS build fails with "Assertion failed: isBulkReadStatement" when using standard sqlite3

Author: iilterCreated Jul 24, 2025Updated Sep 23, 2026
Labelsbug

Duplicate Check

Describe the bug

Describe the bug

When building a Flet app for iOS (either simulator or a real device), the application crashes on launch if it attempts to perform any standard sqlite3 database operation. The crash occurs immediately after the Python script is started by the Swift runner.

The console logs from Xcode show a low-level C++ error: Assertion failed: (0), function isBulkReadStatement, file SQLiteDatabaseTracking.cpp, line 711. This suggests a fundamental incompatibility between the sqlite3 module included in the Flet Python environment for iOS and the underlying native libraries.

To Reproduce

The issue can be reproduced with a minimal test case that only tries to create and write to a SQLite database.

  1. Create a minimal test script (test_sqlite.py):

    python
    import flet as ft
    import os
    import sqlite3
    from pathlib import Path
    
    def main(page: ft.Page):
        page.title = "SQLite Test"
        result_text = ft.Text("Starting test...")
        page.add(result_text)
        page.update()
    
        try:
            # Get the official writable path for mobile
            data_dir = os.getenv("FLET_APP_STORAGE_DATA")
            if not data_dir:
                raise Exception("FLET_APP_STORAGE_DATA not found!")
            
            db_path = os.path.join(data_dir, "test.db")
            
            # Attempt to connect and write to the database
            conn = sqlite3.connect(db_path)
            cursor = conn.cursor()
            cursor.execute("CREATE TABLE IF NOT EXISTS test (id INTEGER, name TEXT)")
            cursor.execute("INSERT INTO test VALUES (1, 'Hello Flet!')")
            conn.commit()
            conn.close()
            
            result_text.value = f"SUCCESS! Database created at:\n{db_path}"
            result_text.color = ft.colors.GREEN
    
        except Exception as e:
            result_text.value = f"ERROR:\n{e}"
            result_text.color = ft.colors.RED
        
        page.update()
    
    ft.app(target=main)
  2. Build the app for iOS:

    bash
    flet build ipa -s test_sqlite.py
  3. Run the app on an iOS simulator or a real device using Xcode. The app will crash right after launch.

Expected behavior

The application should launch without crashing and successfully create, write to, and read from a SQLite database file located in the path provided by the FLET_APP_STORAGE_DATA environment variable.

Environment

  • Flet version: 0.28.3
  • Python version: 3.12
  • Operating system: macOS Sonoma (for building)
  • Target platform: iOS 18.5 Simulator (iPhone 16 Pro) and real Android devices.

Additional context

This issue seems to be a fundamental library incompatibility, not a file permission error related to the path itself. The error occurs even when using the official FLET_APP_STORAGE_DATA path. Attempts to use pysqlite3-binary failed because there are no pre-built wheels for the target mobile platforms. This is a critical blocker for any Flet app on iOS that requires local database storage.

Code sample

Code
python
[Paste your code here]

To reproduce

Set up the environment:

On a macOS machine with Xcode and Python 3.12 installed, create a new Python virtual environment.

Install Flet: pip install flet==0.28.3

Create a minimal reproduction script:

Create a new Python file named ios_sqlite_test.py with the following content. This script does nothing but try to create and write to a SQLite database in the official Flet data directory.

import flet as ft import os import sqlite3 from pathlib import Path

def main(page: ft.Page): page.title = "SQLite Test" page.vertical_alignment = ft.MainAxisAlignment.CENTER page.horizontal_alignment = ft.CrossAxisAlignment.CENTER

result_text = ft.Text("Starting SQLite test...", size=16)
page.add(result_text)
page.update()

try:
    # Get the official writable path for mobile
    data_dir = os.getenv("FLET_APP_STORAGE_DATA")
    if not data_dir:
        raise Exception("FLET_APP_STORAGE_DATA environment variable not found!")

    db_path = os.path.join(data_dir, "test.db")

    # Attempt to connect and write to the database
    conn = sqlite3.connect(db_path)
    cursor = conn.cursor()
    cursor.execute("CREATE TABLE IF NOT EXISTS test (id INTEGER, name TEXT)")
    conn.commit()
    conn.close()

    result_text.value = f"SUCCESS! Database file created at:\n{db_path}"
    result_text.color = ft.colors.GREEN

except Exception as e:
    result_text.value = f"ERROR:\n{e}"
    result_text.color = ft.colors.RED

page.update()

ft.app(target=main)

Build the app for iOS:

Run the Flet build command from the terminal in the same directory:

Bash

flet build ipa -s ios_sqlite_test.py Run in Xcode:

Open the generated Xcode project located at build/flutter/ios/Runner.xcworkspace.

Select an iOS Simulator (e.g., iPhone 16 Pro, iOS 18.5) or a connected physical device as the run target.

Click the "Run" button.

Actual Behavior:

The app crashes immediately on launch. The Xcode console shows a low-level C++ error: Assertion failed: (0), function isBulkReadStatement, file SQLiteDatabaseTracking.cpp, line 711.

Expected behavior

The app should launch without crashing, and the screen should display a "SUCCESS!" message, indicating that the database file was created successfully.

Screenshots / Videos

Captures

[Upload media here]

Operating System

macOS

Operating system details

macOS Sonoma (for building)

Flet version

Flet version:** 0.28.3

Regression

No, it isn't

Suggestions

No response

Logs

Logs
bash
[Paste your logs here]

Additional details

No response