Skip to content

Link core extension statically#344

Merged
simolus3 merged 9 commits into
mainfrom
link-core-extension-statically
Apr 30, 2026
Merged

Link core extension statically#344
simolus3 merged 9 commits into
mainfrom
link-core-extension-statically

Conversation

@simolus3

Copy link
Copy Markdown
Contributor

Currently, we don't link the core extension at all on native platforms. Instead:

  1. We ask users to manually depend on it and then load it as a path.
  2. For our tests, we download desktop libraries and patch the link task of tests to include it.

Following this setup is annoying and error-prone for users, since they have to manage this dependency outside of Gradle and remember to update it every time they upgrade the Kotlin SDK.

This fixes the issue by linking the core extension statically: The :core package uses a cinterop definition with a downloaded static library attached to core extension releases. This embeds the core extension with the built klib, and users don't have to rely on external dependenies anymore. Additionally, it simplifies our loading setup: Previously, we had to use sqlite3_load_extension with a resolved framework path. With static linking, we can simply call sqlite3_auto_extension with the sqlite3_powersync_init function pointer to load the extension.

I've tested the demo app in a simulator and a local framework build for the Swift SDK (that currently causes additional test failures there because Kotlin doesn't support the old sync client anymore, but we're able to load the extension).

Closes #339.

Comment thread core/build.gradle.kts
@simolus3 simolus3 marked this pull request as ready for review April 28, 2026 12:43
@simolus3 simolus3 requested a review from stevensJourney April 28, 2026 12:43

@stevensJourney stevensJourney left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The changes here look good to me. This makes the setup steps much simpler for users. I can't think of any negative repercussions for these changes.

@simolus3 simolus3 merged commit 9df5a9f into main Apr 30, 2026
26 of 35 checks passed
@simolus3 simolus3 deleted the link-core-extension-statically branch April 30, 2026 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

iOS: dyld crash after updating to 1.11.2 — powersync-sqlite-core.framework not embedded

3 participants