packages/swift-client/README.md
A type-safe Swift client for interacting with the Spacedrive daemon.
executeQuery, executeAction, and subscribeAdd this to your Package.swift:
dependencies: [
.package(path: "path/to/spacedrive/packages/swift-client")
]
import SpacedriveClient
// Initialize the client
let client = SpacedriveClient(socketPath: "/path/to/daemon.sock")
// Execute a query
let status = try await client.executeQuery(
CoreStatusQuery(),
method: "query:core.status",
responseType: CoreStatus.self
)
// Execute an action
let result = try await client.executeAction(
LibraryCreateInput(name: "My Library"),
method: "action:libraries.create.input",
responseType: LibraryCreateOutput.self
)
// Subscribe to events
for await event in client.subscribe(to: ["JobProgress", "JobCompleted"]) {
print("Received event: \(event)")
}
After making changes to Rust types in the core:
Build the core to generate the schema:
cd core && cargo build
Regenerate the Swift client:
cd packages/swift-client
./generate_client.sh
npm install -g quicktypeThe client uses a two-layer architecture:
types.swift contains all the generated types from quicktypeSpacedriveClient.swift provides the clean, user-facing APIThis separation ensures that the generated types don't pollute the main API and can be regenerated without affecting user code.