# Swift

The Swift SDK is a macOS-oriented REST/gRPC client for the `antd` daemon.

## Install

```swift
dependencies: [
    .package(path: "../ant-sdk/antd-swift"),
]
```

Use a local package dependency until the package is published.

## Connect to the daemon

```swift
import AntdSdk

let client = AntdClient.createRest(baseURL: "http://localhost:8082")
let status = try await client.health()
print(status.network)
```

## Store and retrieve data

```swift
import AntdSdk

let client = AntdClient.createRest()
let result = try await client.dataPutPublic("Hello, Autonomi!".data(using: .utf8)!)
print(result.address)

let data = try await client.dataGetPublic(address: result.address)
print(String(data: data, encoding: .utf8)!)
```

## Type mappings

| Autonomi type  | Swift type       |
| -------------- | ---------------- |
| `HealthStatus` | Swift model type |
| `PutResult`    | Swift model type |
| Raw data       | `Data`           |

## Error handling

```swift
do {
    let data = try await client.dataGetPublic(address: "nonexistent")
    _ = data
} catch let error as NotFoundError {
    print(error.message)
} catch let error as PaymentError {
    print(error.message)
} catch let error as AntdError {
    print(error.message)
}
```

## Full API reference

For all available daemon endpoints, see the [REST API](/developers/sdk/install/reference/rest-api.md).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.autonomi.com/developers/sdk/install/reference/language-bindings/swift.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
