diff --git a/client-sdk-references/introduction.mdx b/client-sdk-references/introduction.mdx index a5cffe00..6be03096 100644 --- a/client-sdk-references/introduction.mdx +++ b/client-sdk-references/introduction.mdx @@ -16,6 +16,6 @@ Select your client framework for the full SDK reference, getting started instruc Currently in a beta release. - Currently in an alpha release. + Currently in a beta release. diff --git a/client-sdk-references/kotlin-multiplatform.mdx b/client-sdk-references/kotlin-multiplatform.mdx index f75bfd7b..cfd299cb 100644 --- a/client-sdk-references/kotlin-multiplatform.mdx +++ b/client-sdk-references/kotlin-multiplatform.mdx @@ -10,7 +10,7 @@ sidebarTitle: Overview Refer to the powersync-kotlin repo on GitHub. - + A full API Reference for this SDK is not yet available. This is planned for the stable release. @@ -18,6 +18,10 @@ sidebarTitle: Overview + + The PowerSync Swift SDK is currently in a beta release. It is suitable for production use at this stage given you've tested your use cases extensively. Breaking changes are unlikely to occur. + + ### SDK Features * Provides real-time streaming of database changes. diff --git a/client-sdk-references/swift.mdx b/client-sdk-references/swift.mdx index 3d56b64b..d4ffb92e 100644 --- a/client-sdk-references/swift.mdx +++ b/client-sdk-references/swift.mdx @@ -1,22 +1,32 @@ --- -title: "Swift (Alpha)" +title: "Swift (Beta)" sidebarTitle: "Overview" --- + + + Refer to the powersync-swift repo on GitHub. + + + A full API Reference for this SDK is not yet available. This is planned for the stable release. + + + Gallery of example projects/demo apps built with PowerSync and Swift. + + + - The PowerSync Swift SDK is currently in an alpha release. It is not suitable for production use at this stage unless you've tested your use cases extensively. Breaking changes are still likely to occur. + The PowerSync Swift SDK is currently in a beta release. It is suitable for production use at this stage given you've tested your use cases extensively. Breaking changes are unlikely to occur. ## Kotlin Multiplatform -> Native Swift SDK -This SDK is an extension of the [Kotlin Multiplatform SDK](https://github.com/powersync-ja/powersync-kotlin), and utilizes the API tool [SKIE](https://skie.touchlab.co/) to generate and publish a [PowerSync SDK](https://github.com/powersync-ja/powersync-kotlin/tree/main/PowerSync) that can be used in a standalone Swift app. Further details about this configuration can be found in our blog [here](https://www.powersync.com/blog/using-kotlin-multiplatform-with-kmmbridge-and-skie-to-publish-a-native-swift-sdk). - -For the beta, we are moving away from this Kotlin-based architecture towards more Swift-native APIs. For the stable release, will are planning a fully native Swift SDK. +The PowerSync Swift SDK currently makes use of the [PowerSync Kotlin Multiplatform SDK](https://github.com/powersync-ja/powersync-kotlin) with the API tool [SKIE](https://skie.touchlab.co/) and KMMBridge under the hood to help generate and publish a Swift package. We will move to an entirely Swift native SDK in v1 and do not expect there to be any breaking changes. **Demo App** - We recommend the [Supabase Todo List Demo](https://github.com/powersync-ja/powersync-kotlin-swift-demo) app as a starting point for using the Swift SDK. See the README for details to run it. + We recommend the [Supabase Todo List Demo](https://github.com/powersync-ja/powersync-swift/tree/main/Demo) app as a starting point for using the Swift SDK. See the README for details to run it. ### SDK Features @@ -43,11 +53,9 @@ let package = Package( dependencies: [ ... .package( - url: "https://github.com/powersync-ja/powersync-kotlin", - exact: "1.0.0-BETA5.0" - ), - .package( - url: "https://github.com/powersync-ja/powersync-sqlite-core-swift", + url: "https://github.com/powersync-ja/powersync-swift", + // Exact version required while still in beta + exact: "" ), ], targets: [ @@ -56,11 +64,7 @@ let package = Package( dependencies: [ .product( name: "PowerSync", - package: "powersync-kotlin" - ), - .product( - name: "PowerSyncSqliteCore", - package: "powersync-sqlite-core-swift" + package: "powersync-swift" ), ] ) @@ -71,21 +75,22 @@ let package = Package( 2. Using Xcode: 1. Follow [this](https://developer.apple.com/documentation/xcode/adding-package-dependencies-to-your-app#Add-a-package-dependency) guide to add a package to your project. - 2. When searching for the package use [https://github.com/powersync-ja/powersync-kotlin.git](https://github.com/powersync-ja/powersync-kotlin.git) as the URL and include the exact version `1.0.0-BETA5.0` as shown below: + 2. When searching for the package use [https://github.com/powersync-ja/powersync-swift.git](https://github.com/powersync-ja/powersync-swift.git) as the URL and include the exact version e.g. `1.0.0-Beta.x` as shown below: - - + - 3. Do the same for `power-sqlite-core-swift` using [https://github.com/powersync-ja/powersync-sqlite-core-swift.git](https://github.com/powersync-ja/powersync-kotlin.git) and choose a range between `0.3.1` and `0.4.0` as shown below: - - - +### Migrating from the Alpha to the Beta SDK - - Use the exact version for `powersync-kotlin` as we are actively making changes to the Swift SDK which could result in breaking changes. The version history can be found [here](https://central.sonatype.com/artifact/com.powersync/core/versions). - +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 [Todo List Demo app](https://github.com/powersync-ja/powersync-swift/tree/main/Demo) as a reference. ## Getting Started @@ -116,44 +121,37 @@ let lists = Table( name: LISTS_TABLE, columns: [ // ID column is automatically included - Column(name: "name", type: ColumnType.text), - Column(name: "created_at", type: ColumnType.text), - Column(name: "owner_id", type: ColumnType.text) - ], - indexes: [], - localOnly: false, - insertOnly: false, - viewNameOverride: LISTS_TABLE + .text("name"), + .text("created_at"), + .text("owner_id") + ] ) let todos = Table( name: TODOS_TABLE, // ID column is automatically included columns: [ - Column(name: "list_id", type: ColumnType.text), - Column(name: "photo_id", type: ColumnType.text), - Column(name: "description", type: ColumnType.text), + .text("list_id"), + .text("photo_id"), + .text("description"), // 0 or 1 to represent false or true - Column(name: "completed", type: ColumnType.integer), - Column(name: "created_at", type: ColumnType.text), - Column(name: "completed_at", type: ColumnType.text), - Column(name: "created_by", type: ColumnType.text), - Column(name: "completed_by", type: ColumnType.text) + .integer("completed"), + .text("created_at"), + .text("completed_at"), + .text("created_by"), + .text("completed_by") ], indexes: [ Index( name: "list_id", columns: [ - IndexedColumn(column: "list_id", ascending: true, columnDefinition: nil, type: nil) + IndexedColumn.ascending("list_id") ] ) - ], - localOnly: false, - insertOnly: false, - viewNameOverride: TODOS_TABLE + ] ) -let AppSchema = Schema(tables: [lists, todos]) +let AppSchema = Schema(lists, todos) ``` @@ -169,15 +167,11 @@ Its primary function is to record all changes in the local database, whether onl **Example**: ```swift -// Comes from the PowerSync package -let factory = DatabaseDriverFactory() // Comes from the AppSchema defined above let schema = AppSchema -var db = PowerSyncDatabase( - factory: factory, +let db = PowerSyncDatabase( schema: schema, - dbFilename: "powersync-swift.sqlite", - params: [:] + dbFilename: "powersync-swift.sqlite" ) ``` @@ -204,11 +198,10 @@ Accordingly, the connector must implement two methods: import PowerSync @Observable -@MainActor class MyConnector: PowerSyncBackendConnector { override func fetchCredentials() async throws -> PowerSyncCredentials? { // implement fetchCredentials to obtain the necessary credentials to connect to your backend - // See an example implementation in https://github.com/powersync-ja/powersync-kotlin-swift-demo/blob/main/PowerSyncExample/PowerSync/SupabaseConnector.swift + // 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]', @@ -218,7 +211,7 @@ class MyConnector: PowerSyncBackendConnector { } } - override func uploadData(database: any PowerSyncDatabase) async throws { + override func uploadData(database: PowerSyncDatabaseProtocol) async throws { // Implement uploadData to send local changes to your backend service // You can omit this method if you only want to sync data from the server to the client // See an example implementation under Usage Examples (sub-page) @@ -228,10 +221,6 @@ class MyConnector: PowerSyncBackendConnector { ``` - - If you are using **Supabase**, you can use [SupabaseConnector.swift](https://github.com/powersync-ja/powersync-kotlin-swift-demo/blob/main/PowerSyncExample/PowerSync/SupabaseConnector.swift) as a starting point. - - ## Using PowerSync: CRUD functions Once the PowerSync instance is configured you can start using the SQLite DB functions. @@ -311,7 +300,7 @@ func watchLists(_ callback: @escaping (_ lists: [ListContent]) -> Void ) async { ) } ) { - callback(lists as! [ListContent]) + callback(lists) } } ``` @@ -336,12 +325,12 @@ func updateTodo(_ todo: Todo) async throws { } func deleteTodo(id: String) async throws { - try await db.writeTransaction(callback: SuspendTaskWrapper { - try await db.execute( - sql: "DELETE FROM \(TODOS_TABLE) WHERE id = ?", - parameters: [id] - ) + try await db.writeTransaction(callback: { transaction in + _ = try await transaction.execute( + sql: "DELETE FROM \(TODOS_TABLE) WHERE id = ?", + parameters: [id] + ) return }) } -``` \ No newline at end of file +``` diff --git a/images/Swift-Xcode.png b/images/Swift-Xcode.png new file mode 100644 index 00000000..701ef938 Binary files /dev/null and b/images/Swift-Xcode.png differ diff --git a/images/image (1).png b/images/image (1).png deleted file mode 100644 index eaf8b81b..00000000 Binary files a/images/image (1).png and /dev/null differ diff --git a/images/swift.avif b/images/swift.avif deleted file mode 100644 index 451e7a80..00000000 Binary files a/images/swift.avif and /dev/null differ diff --git a/installation/client-side-setup.mdx b/installation/client-side-setup.mdx index 1b554196..d89691bd 100644 --- a/installation/client-side-setup.mdx +++ b/installation/client-side-setup.mdx @@ -18,7 +18,7 @@ The next step after configuring your database and connecting it to your PowerSyn 2. Write mutations to your backend -PowerSync currently supports apps built in [Flutter](/client-sdk-references/flutter), [React Native & Expo](/client-sdk-references/react-native-and-expo), [JavaScript Web](/client-sdk-references/javascript-web), [Kotlin Multiplatform](/client-sdk-references/kotlin-multiplatform) (beta), and [Swift](/client-sdk-references/swift) (alpha). +PowerSync currently supports apps built in [Flutter](/client-sdk-references/flutter), [React Native & Expo](/client-sdk-references/react-native-and-expo), [JavaScript Web](/client-sdk-references/javascript-web), [Kotlin Multiplatform](/client-sdk-references/kotlin-multiplatform) (beta), and [Swift](/client-sdk-references/swift) (beta). Please see the steps based on your app framework: @@ -175,11 +175,8 @@ Please see the steps based on your app framework: dependencies: [ ... .package( - url: "https://github.com/powersync-ja/powersync-kotlin", - exact: "1.0.0-BETA5.0" - ), - .package( - url: "https://github.com/powersync-ja/powersync-sqlite-core-swift", + url: "https://github.com/powersync-ja/powersync-swift", + exact: "" ), ], targets: [ @@ -188,12 +185,8 @@ Please see the steps based on your app framework: dependencies: [ .product( name: "PowerSync", - package: "powersync-kotlin" - ), - .product( - name: "PowerSyncSqliteCore", - package: "powersync-sqlite-core-swift" - ), + package: "powersync-swift" + ) ] ) ] @@ -203,26 +196,15 @@ Please see the steps based on your app framework: 2. Using Xcode: 1. Follow [this](https://developer.apple.com/documentation/xcode/adding-package-dependencies-to-your-app#Add-a-package-dependency) guide to add a package to your project. + 2. When searching for the package use [https://github.com/powersync-ja/powersync-swift.git](https://github.com/powersync-ja/powersync-swift.git) as the URL and include the exact version e.g. `1.0.0-Beta.x` as shown below: - 2. When searching for the package use [https://github.com/powersync-ja/powersync-kotlin.git](https://github.com/powersync-ja/powersync-kotlin.git) as the URL and include the exact version `1.0.0-BETA5.0` as shown below: - - - - - - 3. Do the same for `power-sqlite-core-swift` using [https://github.com/powersync-ja/powersync-sqlite-core-swift.git](https://github.com/powersync-ja/powersync-kotlin.git) and choose a range between `0.3.1` and `0.4.0` as shown below: - - - - - - - Use the exact version for `powersync-kotlin` as we are actively making changes to the Swift SDK which could result in breaking changes. The version history can be found [here](https://central.sonatype.com/artifact/com.powersync/core/versions). - + + + See the full SDK reference for further details and getting started instructions: - + ## Next Steps @@ -235,4 +217,4 @@ For an overview of the client-side steps required to set up PowerSync in your ap 3. [Integrate with your Backend](/installation/client-side-setup/integrating-with-your-backend) -For a walkthrough with example implementations for your platform, see the *Getting Started* section of the corresponding SDK reference linked above. \ No newline at end of file +For a walkthrough with example implementations for your platform, see the *Getting Started* section of the corresponding SDK reference linked above. diff --git a/integration-guides/supabase-+-powersync.mdx b/integration-guides/supabase-+-powersync.mdx index bd7e493f..f08d90ea 100644 --- a/integration-guides/supabase-+-powersync.mdx +++ b/integration-guides/supabase-+-powersync.mdx @@ -183,9 +183,9 @@ git clone https://github.com/powersync-ja/powersync-kotlin.git ``` ```bash Swift -git clone git@github.com:powersync-ja/powersync-kotlin-swift-demo.git +git clone https://github.com/powersync-ja/powersync-swift.git -# Open the project in XCode and follow the README instructions. +# Open the Demo directory in XCode and follow the README instructions. ``` diff --git a/intro/powersync-overview.mdx b/intro/powersync-overview.mdx index 39c40b6c..e5864f81 100644 --- a/intro/powersync-overview.mdx +++ b/intro/powersync-overview.mdx @@ -47,7 +47,7 @@ PowerSync is also designed to be client-side stack agnostic, and currently has c - Currently in an alpha release. + Currently in a beta release. @@ -159,4 +159,4 @@ Explore and learn from example implementations and common use cases with PowerSy Learn about the philosophy behind PowerSync and why we built it. - \ No newline at end of file + diff --git a/migration-guides/mongodb-atlas.mdx b/migration-guides/mongodb-atlas.mdx index 6a90bac4..c0dc5922 100644 --- a/migration-guides/mongodb-atlas.mdx +++ b/migration-guides/mongodb-atlas.mdx @@ -78,11 +78,11 @@ We are constantly adding additional PowerSync Client SDKs and some of them are u | Flavor | Status | ETA | | ------------------------------------------------------------------- | ----------- | ---------------- | -| [JavaScript/Web](/client-sdk-references/javascript-web) | Stable | N/A | +| [JavaScript/Web](/client-sdk-references/javascript-web) | Stable | N/A | | [React Native](/client-sdk-references/react-native-and-expo) & Expo | Stable | N/A | | [Flutter/Dart](/client-sdk-references/flutter) | Stable | N/A | | [Kotlin Multiplatform](/client-sdk-references/kotlin-multiplatform) | Beta | V1 ETA 2025Q1 | -| [Swift](/client-sdk-references/swift) | Alpha | Beta ETA 2024Q4 | +| [Swift](/client-sdk-references/swift) | Beta | V1 ETA 2025Q1 | | Node.js | PoC | Alpha ETA 2024Q4 | | .NET | Not Started | Alpha ETA 2025Q1 | diff --git a/resources/demo-apps-example-projects.mdx b/resources/demo-apps-example-projects.mdx index df09b7d4..4be45df1 100644 --- a/resources/demo-apps-example-projects.mdx +++ b/resources/demo-apps-example-projects.mdx @@ -109,7 +109,7 @@ For example implementations and details of common use cases, see [Use Case Examp **Supabase Backend:** -* [To-Do List App](https://github.com/powersync-ja/powersync-kotlin-swift-demo) +* [To-Do List App](https://github.com/powersync-ja/powersync-swift/tree/main/Demo) ## Custom Backend Examples @@ -171,4 +171,4 @@ For example implementations and details of common use cases, see [Use Case Examp * Testing PowerSync with Jepsen for formal consistency validation - * [https://github.com/nurturenature/jepsen-powersync](https://github.com/nurturenature/jepsen-powersync) \ No newline at end of file + * [https://github.com/nurturenature/jepsen-powersync](https://github.com/nurturenature/jepsen-powersync) diff --git a/usage/use-case-examples/full-text-search.mdx b/usage/use-case-examples/full-text-search.mdx index f5c48bae..b9d8bf2c 100644 --- a/usage/use-case-examples/full-text-search.mdx +++ b/usage/use-case-examples/full-text-search.mdx @@ -15,11 +15,11 @@ Currently, FTS is supported in: * Relies on the [sqlite\_async](https://pub.dev/documentation/sqlite_async/latest/) package for migrations * **Web:** [powersync-sdk-web](https://github.com/powersync-ja/powersync-js/blob/main/packages/web/README.md) ([JavaScript Web SDK](/client-sdk-references/javascript-web)) * Requires version 0.5.0 or greater of the SDK (incl. version 0.2.0 of the [wa-sqlite](https://github.com/powersync-ja/wa-sqlite) package) +* [Kotlin](/client-sdk-references/kotlin-multiplatform) +* [Swift](/client-sdk-references/swift) **React Native:** SQLite recursive triggers are supported in the [React Native SDK](/client-sdk-references/react-native-and-expo), and it should be possible to implement FTS with some additional config. [This issue](https://github.com/ospfranco/react-native-quick-sqlite/issues/37) could be a good starting point. -**Kotlin and Swift**: FTS support for [Kotlin](/client-sdk-references/kotlin-multiplatform) and [Swift](/client-sdk-references/swift) is planned. [Let us know](/resources/contact-us) if you require this for your project. - ## Example Implementations FTS is implemented in the following demo apps: