Skip to content

Link SQLite statically on native platforms #147

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 20, 2025

Conversation

simolus3
Copy link
Contributor

All our client SDKs need the PowerSync core extension to be loaded to work. On Apple platforms however, SQLite extension loading is disabled. This means that our SDK must not link the SQLite library from the platform, and instead link a custom version compiled with extension support.

This:

  1. Removes the last remnants of native builds in the :core project. We don't need it for Android since we're now using sqlite-jdbc. We also don't need it for iOS since we can call the cinterop methods exposed from the SQLiter dependency.
  2. Disables linking SQLite with the option provided by SQLDelight (since that one uses the one from the system).
  3. Adds a new project whose only purpose is to compile sqlite3 into a static archive. This archive is then included on a cinterop definition. This makes the Kotlin compiler bundle the archive with the klib, dependents will automatically link it.
  4. Depend on the new project from :persistence. This means that we now link SQLite statically.

@simolus3 simolus3 requested a review from stevensJourney March 19, 2025 14:37
Copy link
Contributor

@stevensJourney stevensJourney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!!!! i tested this for both debug and release builds of the Supabase Compose demo. I confirmed a debug build of the Swift demo also works.

@simolus3 simolus3 merged commit 458c84d into concurrent Mar 20, 2025
@simolus3 simolus3 deleted the native-static-link-sqlite branch March 20, 2025 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants