You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+56-19Lines changed: 56 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,11 +8,13 @@ _[PowerSync](https://www.powersync.com) is a sync engine for building local-firs
8
8
9
9
This is the PowerSync SDK for Swift clients. The SDK reference is available [here](https://docs.powersync.com/client-sdk-references/swift), API references are [documented here](https://powersync-ja.github.io/powersync-swift/documentation/powersync/).
10
10
11
-
## Structure: Packages
11
+
## Available Products
12
12
13
-
-[Sources](./Sources/)
13
+
The SDK provides two main products:
14
14
15
-
- This is the Swift SDK implementation.
15
+
-**PowerSync**: Core SDK with SQLite support for data synchronization.
16
+
-**PowerSyncDynamic**: Forced dynamically linked version of `PowerSync` - useful for XCode previews.
17
+
-**PowerSyncGRDB [ALPHA]**: GRDB integration allowing PowerSync to work with GRDB databases. This product is currently in an alpha release.
16
18
17
19
## Demo Apps / Example Projects
18
20
@@ -38,6 +40,11 @@ Add
38
40
name: "PowerSync",
39
41
package: "powersync-swift"
40
42
),
43
+
// Optional: Add if using GRDB
44
+
.product(
45
+
name: "PowerSyncGRDB",
46
+
package: "powersync-swift"
47
+
)
41
48
]
42
49
)
43
50
]
@@ -47,29 +54,59 @@ to your `Package.swift` file.
47
54
48
55
## Usage
49
56
50
-
Create a PowerSync client
57
+
### Basic PowerSync Setup
51
58
52
59
```swift
53
60
importPowerSync
54
61
55
-
let powersync =PowerSyncDatabase(
56
-
schema: Schema(
57
-
tables: [
58
-
Table(
59
-
name: "users",
60
-
columns: [
61
-
.text("count"),
62
-
.integer("is_active"),
63
-
.real("weight"),
64
-
.text("description")
65
-
]
66
-
)
67
-
]
68
-
),
62
+
let mySchema =Schema(
63
+
tables: [
64
+
Table(
65
+
name: "users",
66
+
columns: [
67
+
.text("count"),
68
+
.integer("is_active"),
69
+
.real("weight"),
70
+
.text("description")
71
+
]
72
+
)
73
+
]
74
+
)
75
+
76
+
let powerSync =PowerSyncDatabase(
77
+
schema: mySchema,
69
78
logger: DefaultLogger(minSeverity: .debug)
70
79
)
71
80
```
72
81
82
+
### GRDB Integration
83
+
84
+
If you're using [GRDB.swift](https://github.com/groue/GRDB.swift) by [Gwendal Roué](https://github.com/groue), you can integrate PowerSync with your existing database. Special thanks to Gwendal for their help in developing this integration.
85
+
86
+
**⚠️ Note:** The GRDB integration is currently in **alpha** release and the API may change significantly. While functional, it should be used with caution in production environments.
87
+
88
+
```swift
89
+
importPowerSync
90
+
importPowerSyncGRDB
91
+
importGRDB
92
+
93
+
// Configure GRDB with PowerSync support
94
+
var config =Configuration()
95
+
config.configurePowerSync(schema: mySchema)
96
+
97
+
// Create database with PowerSync enabled
98
+
let dbPool =tryDatabasePool(
99
+
path: dbPath,
100
+
configuration: config
101
+
)
102
+
103
+
let powerSync =tryopenPowerSyncWithGRDB(
104
+
pool: dbPool,
105
+
schema: mySchema,
106
+
identifier: "app-db"
107
+
)
108
+
```
109
+
73
110
## Underlying Kotlin Dependency
74
111
75
112
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.
@@ -89,4 +126,4 @@ XCode previews can be enabled by either:
89
126
90
127
Enabling `Editor -> Canvas -> Use Legacy Previews Execution` in XCode.
91
128
92
-
Or adding the `PowerSyncDynamic` product when adding PowerSync to your project. This product will assert that PowerSync should be dynamically linked, which restores XCode previews.
129
+
Or adding the `PowerSyncDynamic` product when adding PowerSync to your project. This product will assert that PowerSync should be dynamically linked, which restores XCode previews.
0 commit comments