Skip to content

Commit a81986e

Browse files
Update READMEs
1 parent 7beff16 commit a81986e

File tree

5 files changed

+64
-6
lines changed

5 files changed

+64
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## 1.6.1 (unreleased)
44

55
* Update Kotlin SDK to 1.7.0.
6+
* Added Alpha `PowerSyncGRDB` product which supports sharing GRDB `DatabasePool`s with PowerSync and application logic.
67

78
## 1.6.0
89

Demo/GRDB Demo/GRDB Demo/GRDB_DemoApp.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,9 @@ func openDatabase()
4444
fatalError("Could not open database")
4545
}
4646

47-
let powerSync = OpenedPowerSyncDatabase(
47+
let powerSync = openPowerSyncWithGRDB(
48+
pool: grdb,
4849
schema: schema,
49-
pool: GRDBConnectionPool(
50-
pool: grdb
51-
),
5250
identifier: "test"
5351
)
5452

Demo/GRDB Demo/GRDB Demo/README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# PowerSync Swift GRDB Demo App
2+
3+
A Todo List app demonstrating the use of the PowerSync Swift SDK with GRDB and Supabase.
4+
5+
## Set up your Supabase and PowerSync projects
6+
7+
To run this demo, you need Supabase and PowerSync projects. Detailed instructions for integrating PowerSync with Supabase can be found in [the integration guide](https://docs.powersync.com/integration-guides/supabase).
8+
9+
Follow this guide to:
10+
11+
1. Create and configure a Supabase project.
12+
2. Create a new PowerSync instance, connecting to the database of the Supabase project. See instructions [here](https://docs.powersync.com/integration-guides/supabase-+-powersync#connect-powersync-to-your-supabase).
13+
3. Deploy sync rules.
14+
15+
## Configure The App
16+
17+
1. Open this directory in XCode.
18+
19+
2. Copy the `_Secrets.swift` file to a new `Secrets.swift` file and insert the credentials of your Supabase and PowerSync projects (more info can be found [here](https://docs.powersync.com/integration-guides/supabase-+-powersync#test-everything-using-our-demo-app)).
20+
21+
```bash
22+
cp _Secrets.swift Secrets.swift
23+
```
24+
25+
### GRDB Implementation Details
26+
27+
This demo uses GRDB.swift for local data storage and querying. The key differences from the standard PowerSync demo are:
28+
29+
1. Queries and mutations are handled using GRDB's data access patterns
30+
2. Observable database queries are implemented using GRDB's ValueObservation
31+
32+
### Troubleshooting
33+
34+
If you run into build issues, try:
35+
36+
1. Clear Swift caches
37+
38+
```bash
39+
rm -rf ~/Library/Caches/org.swift.swiftpm
40+
rm -rf ~/Library/org.swift.swiftpm
41+
```
42+
43+
2. In Xcode:
44+
45+
- Reset Packages: File -> Packages -> Reset Package Caches
46+
- Clean Build: Product -> Clean Build Folder.
47+
48+
## Run project
49+
50+
Build the project, launch the app and sign in or register a new user. The app demonstrates real-time synchronization of todo lists between multiple devices and the cloud, powered by PowerSync's offline-first architecture and GRDB's robust local database capabilities.

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ let packageName = "PowerSync"
77

88
// Set this to the absolute path of your Kotlin SDK checkout if you want to use a local Kotlin
99
// build. Also see docs/LocalBuild.md for details
10-
let localKotlinSdkOverride: String? = "/Users/stevenontong/Documents/platform_code/powersync/powersync-kotlin"
10+
let localKotlinSdkOverride: String? = "/Users/stevenontong/Documents/platform_code/powersync/powersync-kotlin/internal"
1111

1212
// Set this to the absolute path of your powersync-sqlite-core checkout if you want to use a
1313
// local build of the core extension.

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ The easiest way to test the PowerSync Swift SDK is to run our demo application.
2222

2323
- [Demo/PowerSyncExample](./Demo/README.md): A simple to-do list application demonstrating the use of the PowerSync Swift SDK using a Supabase connector.
2424

25+
- [Demo/GRDB Demo](./Demo/README.md): A simple to-do list application demonstrating the use of the PowerSync Swift SDK using a Supabase connector and GRDB connections.
26+
2527
## Installation
2628

2729
Add
@@ -103,10 +105,17 @@ let dbPool = try DatabasePool(
103105
let powerSync = try openPowerSyncWithGRDB(
104106
pool: dbPool,
105107
schema: mySchema,
106-
identifier: "app-db"
108+
identifier: "app-db.sqlite"
107109
)
108110
```
109111

112+
Feel free to use the `DatabasePool` for view logic and the `PowerSyncDatabase` for PowerSync operations.
113+
114+
#### Limitations
115+
116+
- Updating the PowerSync schema, with `updateSchema`, is not currently fully supported with GRDB connections.
117+
- This integration requires currently statically linking PowerSync and GRDB.
118+
110119
## Underlying Kotlin Dependency
111120

112121
The PowerSync Swift SDK makes use of the [PowerSync Kotlin Multiplatform SDK](https://github.com/powersync-ja/powersync-kotlin) and the API tool [SKIE](https://skie.touchlab.co/) under the hood to implement the Swift package.

0 commit comments

Comments
 (0)