Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
2420647
instantiate logger directly
stevensJourney Aug 18, 2025
5807b0c
update xcode action
stevensJourney Aug 18, 2025
6c8d882
update device name
stevensJourney Aug 18, 2025
4bb21a8
update watch tests
stevensJourney Aug 18, 2025
556c1f0
Mark protocols as Sendable
stevensJourney Aug 20, 2025
2dc0d8d
wip: declare items as Sendable
stevensJourney Aug 21, 2025
8856741
more lock improvements
stevensJourney Aug 21, 2025
330bea1
Improve lock error handling
stevensJourney Aug 21, 2025
e88acfe
Merge remote-tracking branch 'origin/main' into lock-improvements
stevensJourney Aug 21, 2025
5ad57a0
cleanup
stevensJourney Aug 21, 2025
1efaef8
Merge branch 'lock-improvements' into swift-concurrency
stevensJourney Aug 21, 2025
80594f1
Improve Sendable of AttachmentsImplementations
stevensJourney Aug 21, 2025
6496820
Update connector for Sendable
stevensJourney Aug 21, 2025
aa4a4f0
cleanup more Sendables
stevensJourney Aug 21, 2025
fcde47f
add tests for Swift 6 compile
stevensJourney Aug 21, 2025
9b343ca
Cleanup example demo
stevensJourney Aug 21, 2025
c444032
Move more to extensions
stevensJourney Aug 22, 2025
c84b4e9
cleanup attachments
stevensJourney Aug 25, 2025
c93c5e1
update changelog
stevensJourney Aug 25, 2025
e1f1188
stragler fixes
stevensJourney Aug 25, 2025
c628ecf
revert to 5.7 after test
stevensJourney Aug 25, 2025
17e4c5f
update readme
stevensJourney Aug 25, 2025
0547ed2
Update connector for better Sendable support
stevensJourney Aug 25, 2025
44c64d0
Merge remote-tracking branch 'origin/main' into swift-concurrency
stevensJourney Aug 26, 2025
5e0b1f6
update connector for swift 6 in tests
stevensJourney Aug 26, 2025
1ce6e3b
remove dependency override
stevensJourney Aug 26, 2025
1a33db6
update Swift 6 test script
stevensJourney Aug 26, 2025
b668f4c
update changelog
stevensJourney Aug 26, 2025
9c208fd
Merge branch 'main' into swift-concurrency
stevensJourney Aug 26, 2025
8dcb0f1
code cleanup
stevensJourney Aug 26, 2025
3aa86bf
Merge branch 'swift-concurrency' of github.com:powersync-ja/powersync…
stevensJourney Aug 26, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/build_and_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,20 @@ jobs:
xcodebuild test -scheme PowerSync -destination "platform=iOS Simulator,name=iPhone 16"
xcodebuild test -scheme PowerSync -destination "platform=macOS,arch=arm64,name=My Mac"
xcodebuild test -scheme PowerSync -destination "platform=watchOS Simulator,arch=arm64,name=Apple Watch Ultra 2 (49mm)"

buildSwift6:
name: Build and test with Swift 6
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Set up XCode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
- name: Use Swift 6
run: |
sed -i '' 's|^// swift-tools-version:.*$|// swift-tools-version:6.1|' Package.swift
- name: Build and Test
run: |
swift build -Xswiftc -strict-concurrency=complete
swift test -Xswiftc -strict-concurrency=complete
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ DerivedData/
.swiftpm/configuration/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc

.vscode
.sourcekit-lsp

Secrets.swift
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
## Unreleased

* Fix null values in CRUD entries being reported as strings.
* Added support for Swift 6 strict concurrency checking.
- Accepted query parameter types have been updated from `[Any]` to `[Sendable]`. This should cover all supported query parameter types.
- Query and lock methods' return `Result` generic types now should extend `Sendable`.
- Deprecated default `open class PowerSyncBackendConnector`. Devs should preferably implement the `PowerSyncBackendConnectorProtocol`

* *Potential Breaking Change*: Attachment helpers have been updated to better support Swift 6 strict concurrency checking. `Actor` isolation is improved, but developers who customize or extend `AttachmentQueue` will need to update their implementations. The default instantiation of `AttachmentQueue` remains unchanged.
`AttachmentQueueProtocol` now defines the basic requirements for an attachment queue, with most base functionality provided via an extension. Custom implementations should extend `AttachmentQueueProtocol`.
* [Internal] Instantiate Kotlin Kermit logger directly.
* [Internal] Improved connection context error handling.

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions Demo/PowerSyncExample/PowerSync/SupabaseConnector.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ private enum PostgresFatalCodes {
}

@Observable
class SupabaseConnector: PowerSyncBackendConnector {
final class SupabaseConnector: PowerSyncBackendConnectorProtocol {
let powerSyncEndpoint: String = Secrets.powerSyncEndpoint
let client: SupabaseClient = .init(
supabaseURL: Secrets.supabaseURL,
Expand All @@ -50,8 +50,7 @@ class SupabaseConnector: PowerSyncBackendConnector {
@ObservationIgnored
private var observeAuthStateChangesTask: Task<Void, Error>?

override init() {
super.init()
init() {
session = client.auth.currentSession
observeAuthStateChangesTask = Task { [weak self] in
guard let self = self else { return }
Expand Down Expand Up @@ -80,7 +79,7 @@ class SupabaseConnector: PowerSyncBackendConnector {
return client.storage.from(bucket)
}

override func fetchCredentials() async throws -> PowerSyncCredentials? {
func fetchCredentials() async throws -> PowerSyncCredentials? {
session = try await client.auth.session

if session == nil {
Expand All @@ -92,7 +91,7 @@ class SupabaseConnector: PowerSyncBackendConnector {
return PowerSyncCredentials(endpoint: powerSyncEndpoint, token: token)
}

override func uploadData(database: PowerSyncDatabaseProtocol) async throws {
func uploadData(database: PowerSyncDatabaseProtocol) async throws {
guard let transaction = try await database.getNextCrudTransaction() else { return }

var lastEntry: CrudEntry?
Expand Down
8 changes: 4 additions & 4 deletions Demo/PowerSyncExample/PowerSync/SystemManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -225,17 +225,17 @@ class SystemManager {
if let attachments, let photoId = todo.photoId {
try await attachments.deleteFile(
attachmentId: photoId
) { tx, _ in
) { transaction, _ in
try self.deleteTodoInTX(
id: todo.id,
tx: tx
tx: transaction
)
}
} else {
try await db.writeTransaction { tx in
try await db.writeTransaction { transaction in
try self.deleteTodoInTX(
id: todo.id,
tx: tx
tx: transaction
)
}
}
Expand Down
24 changes: 12 additions & 12 deletions Sources/PowerSync/Kotlin/DatabaseLogger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@ import PowerSyncKotlin
private class KermitLogWriterAdapter: Kermit_coreLogWriter {
/// The underlying Swift log writer to forward log messages to.
let logger: any LoggerProtocol

/// Initializes a new adapter.
///
/// - Parameter logger: A Swift log writer that will handle log output.
init(logger: any LoggerProtocol) {
self.logger = logger
super.init()
}

/// Called by Kermit to log a message.
///
/// - Parameters:
/// - severity: The severity level of the log.
/// - message: The content of the log message.
/// - tag: A string categorizing the log.
/// - throwable: An optional Kotlin exception (ignored here).
override func log(severity: Kermit_coreSeverity, message: String, tag: String, throwable: KotlinThrowable?) {
override func log(severity: Kermit_coreSeverity, message: String, tag: String, throwable _: KotlinThrowable?) {
switch severity {
case PowerSyncKotlin.Kermit_coreSeverity.verbose:
return logger.debug(message, tag: tag)
Expand All @@ -43,7 +43,7 @@ private class KermitLogWriterAdapter: Kermit_coreLogWriter {
class KotlinKermitLoggerConfig: PowerSyncKotlin.Kermit_coreLoggerConfig {
var logWriterList: [Kermit_coreLogWriter]
var minSeverity: PowerSyncKotlin.Kermit_coreSeverity

init(logWriterList: [Kermit_coreLogWriter], minSeverity: PowerSyncKotlin.Kermit_coreSeverity) {
self.logWriterList = logWriterList
self.minSeverity = minSeverity
Expand All @@ -54,46 +54,46 @@ class KotlinKermitLoggerConfig: PowerSyncKotlin.Kermit_coreLoggerConfig {
///
/// This class bridges Swift log writers with the Kotlin logging system and supports
/// runtime configuration of severity levels and writer lists.
class DatabaseLogger: LoggerProtocol {
final class DatabaseLogger: LoggerProtocol {
/// The underlying Kermit logger instance provided by the PowerSyncKotlin SDK.
public let kLogger: PowerSyncKotlin.KermitLogger
public let logger: any LoggerProtocol

/// Initializes a new logger with an optional list of writers.
///
/// - Parameter logger: A logger which will be called for each internal log operation
init(_ logger: any LoggerProtocol) {
self.logger = logger
// Set to the lowest severity. The provided logger should filter by severity
self.kLogger = PowerSyncKotlin.KermitLogger(
kLogger = PowerSyncKotlin.KermitLogger(
config: KotlinKermitLoggerConfig(
logWriterList: [KermitLogWriterAdapter(logger: logger)],
minSeverity: Kermit_coreSeverity.verbose
),
tag: "PowerSync"
)
}

/// Logs a debug-level message.
public func debug(_ message: String, tag: String?) {
logger.debug(message, tag: tag)
}

/// Logs an info-level message.
public func info(_ message: String, tag: String?) {
logger.info(message, tag: tag)
}

/// Logs a warning-level message.
public func warning(_ message: String, tag: String?) {
logger.warning(message, tag: tag)
}

/// Logs an error-level message.
public func error(_ message: String, tag: String?) {
logger.error(message, tag: tag)
}

/// Logs a fault (assert-level) message, typically used for critical issues.
public func fault(_ message: String, tag: String?) {
logger.fault(message, tag: tag)
Expand Down
Loading
Loading