Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion Sources/PowerSync/Kotlin/KotlinPowerSyncDatabaseImpl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ final class KotlinPowerSyncDatabaseImpl: PowerSyncDatabaseProtocol,
params: resolvedOptions.params.mapValues { $0.toKotlinMap() },
options: createSyncOptions(
newClient: resolvedOptions.newClientImplementation,
userAgent: "PowerSync Swift SDK",
userAgent: userAgent(),
loggingConfig: resolvedOptions.clientConfiguration?.requestLogger?.toKotlinConfig()
)
)
Expand Down
25 changes: 25 additions & 0 deletions Sources/PowerSync/Kotlin/sync/UserAgent.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import Foundation

#if os(iOS)
import UIKit
#elseif os(macOS)
import AppKit
#endif

func userAgent() -> String {
let libraryVersion = "1.0.0" // TODO: Replace with actual library version
Copy link
Author

@Chriztiaan Chriztiaan Dec 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't see a clear way that we access this currently. For Kotlin we manage a LIBRARY_VERSION variable in the gradle.properties.
Is that a similar mechanism we want to follow?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good point, I don't think we can automate this with SwiftPM alone. What might work is to:

  1. Add a Sources/PowerSync/CurrentVersion.swift with an internal libraryVersion string constant.
  2. In the release.yml workflow, update that constant with ${{ github.event.inputs.version }}.
  3. Commit that file in the action before creating the tag.


#if os(iOS)
let osName = "iOS"
let osVersion = UIDevice.current.systemVersion
#elseif os(macOS)
let osName = "macOS"
let version = ProcessInfo.processInfo.operatingSystemVersion
let osVersion = "\(version.majorVersion).\(version.minorVersion)"
#else
let osName = "unknown"
let osVersion = ProcessInfo.processInfo.operatingSystemVersionString
#endif

return "powersync-swift/\(libraryVersion) \(osName)/\(osVersion)"
}