diff --git a/client-sdk-references/swift.mdx b/client-sdk-references/swift.mdx
index 047f0ff0..4d586462 100644
--- a/client-sdk-references/swift.mdx
+++ b/client-sdk-references/swift.mdx
@@ -81,17 +81,6 @@ let package = Package(
-### Migrating from the Alpha to the Beta SDK
-
-The beta version of this SDK introduces a Swift-native wrapper around the package generated from the Kotlin Multiplatform SDK, bringing a more Swift-native interface for developers. This results in several API updates from the more Kotlin-based alpha version. The main changes are:
-* The `PowerSyncDatabase` no longer needs a driver argument and it must be removed.
-* The interface for `PowerSyncDatabase` now uses `PowerSyncDatabaseProtocol` which may require some changes to databases uses.
-* If you were using `__uploadData` and `__fetchCredentials` in your `PowerSyncBackendConnector` you must remove the `__` and update the methods to `uploadData` and `fetchCredentials`.
-* `@MainThread` usage is no longer required and should be removed.
-* Implementing `SuspendTaskWrapper` for database transactions is no longer required and should be removed.
-
-See the [To-Do List Demo app](https://github.com/powersync-ja/powersync-swift/tree/main/Demo) as a reference.
-
## Getting Started
Before implementing the PowerSync SDK in your project, make sure you have completed these steps:
@@ -203,12 +192,12 @@ class MyConnector: PowerSyncBackendConnector {
// implement fetchCredentials to obtain the necessary credentials to connect to your backend
// See an example implementation in https://github.com/powersync-ja/powersync-swift/blob/main/Demo/PowerSyncExample/PowerSync/SupabaseConnector.swift
- return {
- endpoint: '[Your PowerSync instance URL or self-hosted endpoint]',
+ return PowerSyncCredentials(
+ endpoint: "Your PowerSync instance URL or self-hosted endpoint",
// Use a development token (see Authentication Setup https://docs.powersync.com/installation/authentication-setup/development-tokens)
// to get up and running quickly) to get up and running quickly
- token: 'An authentication token'
- }
+ token: "An authentication token"
+ )
}
override func uploadData(database: PowerSyncDatabaseProtocol) async throws {
@@ -288,19 +277,23 @@ The `watch` method executes a read query whenever a change to a dependent table
```swift
// You can watch any SQL query
func watchLists(_ callback: @escaping (_ lists: [ListContent]) -> Void ) async {
- for await lists in self.db.watch(
- sql: "SELECT * FROM \(LISTS_TABLE)",
- parameters: [],
- mapper: { cursor in
- ListContent(
- id: try cursor.getString(name: "id")!,
- name: try cursor.getString(name: "name")!,
- createdAt: try cursor.getString(name: "created_at")!,
- ownerId: try cursor.getString(name: "owner_id")!
- )
+ do {
+ for try await lists in try self.db.watch(
+ sql: "SELECT * FROM \(LISTS_TABLE)",
+ parameters: [],
+ mapper: { cursor in
+ try ListContent(
+ id: cursor.getString(name: "id"),
+ name: cursor.getString(name: "name"),
+ createdAt: cursor.getString(name: "created_at"),
+ ownerId: cursor.getString(name: "owner_id")
+ )
+ }
+ ) {
+ callback(lists)
}
- ) {
- callback(lists)
+ } catch {
+ print("Error in watch: \(error)")
}
}
```
@@ -326,11 +319,10 @@ func updateTodo(_ todo: Todo) async throws {
func deleteTodo(id: String) async throws {
try await db.writeTransaction(callback: { transaction in
- _ = transaction.execute(
+ _ = try transaction.execute(
sql: "DELETE FROM \(TODOS_TABLE) WHERE id = ?",
parameters: [id]
)
- return
})
}
```
diff --git a/client-sdk-references/swift/migrating-from-alpha-to-beta.mdx b/client-sdk-references/swift/migrating-from-alpha-to-beta.mdx
new file mode 100644
index 00000000..3200992b
--- /dev/null
+++ b/client-sdk-references/swift/migrating-from-alpha-to-beta.mdx
@@ -0,0 +1,14 @@
+---
+title: "Migrating from Alpha to Beta"
+---
+
+### Steps to migrate
+
+The beta version of this SDK introduces a Swift-native wrapper around the package generated from the Kotlin Multiplatform SDK, bringing a more Swift-native interface for developers. This results in several API updates from the more Kotlin-based alpha version. The main changes are:
+* The `PowerSyncDatabase` no longer needs a driver argument and it must be removed.
+* The interface for `PowerSyncDatabase` now uses `PowerSyncDatabaseProtocol` which may require some changes to databases uses.
+* If you were using `__uploadData` and `__fetchCredentials` in your `PowerSyncBackendConnector` you must remove the `__` and update the methods to `uploadData` and `fetchCredentials`.
+* `@MainThread` usage is no longer required and should be removed.
+* Implementing `SuspendTaskWrapper` for database transactions is no longer required and should be removed.
+
+See the [To-Do List Demo app](https://github.com/powersync-ja/powersync-swift/tree/main/Demo) as a reference.
diff --git a/migration-guides/mongodb-atlas.mdx b/migration-guides/mongodb-atlas.mdx
index 7b9d9bd1..1c884e54 100644
--- a/migration-guides/mongodb-atlas.mdx
+++ b/migration-guides/mongodb-atlas.mdx
@@ -312,7 +312,7 @@ Now that we have our Sync Rules and client-side schema defined, we can instantia
```swift Swift
let schema = AppSchema
- let connector = Connector();
+ let connector = Connector(); // This connector must conform to PowerSyncBackendConnector
let db = PowerSyncDatabase(
schema: schema,
diff --git a/mint.json b/mint.json
index 9c70c42e..27d49708 100644
--- a/mint.json
+++ b/mint.json
@@ -334,7 +334,8 @@
"group": "Swift",
"icon": "swift",
"pages": [
- "client-sdk-references/swift"
+ "client-sdk-references/swift",
+ "client-sdk-references/swift/migrating-from-alpha-to-beta"
]
}
]
@@ -598,4 +599,4 @@
"youtube": "https://www.youtube.com/@powersync_",
"linkedin": "https://www.linkedin.com/showcase/journeyapps-powersync/"
}
-}
\ No newline at end of file
+}