For the complete documentation index, see llms.txt. This page is also available as Markdown.

Swift

Use the Swift SDK to store and retrieve data through a local daemon, a background service called antd. The client supports REST and gRPC.

Install

The binding is not published as a remote Swift package for ant-sdk v0.12.1. Use Swift 5.9 or later, macOS 15 or later, and reference the exact release source as a local package. The released package declares macOS 13, but its public DaemonDiscovery API exposes a macOS-15-only gRPC type without an availability guard, so the combined package does not build with the declared macOS 13 target.

git clone --branch v0.12.1 --depth 1 https://github.com/WithAutonomi/ant-sdk.git
test "$(git -C ant-sdk rev-parse HEAD)" = "f9cd5c5fc08133847909e47e04af186593ccbaee"
mkdir AutonomiExample
cd AutonomiExample
swift package init --type executable
rm Sources/main.swift
mkdir -p Sources/AutonomiExample

Use this complete Package.swift file while AutonomiExample and ant-sdk share a parent directory:

// swift-tools-version: 5.9

import PackageDescription

let package = Package(
    name: "AutonomiExample",
    platforms: [.macOS(.v15)],
    dependencies: [
        .package(path: "../ant-sdk/antd-swift"),
    ],
    targets: [
        .executableTarget(
            name: "AutonomiExample",
            dependencies: [
                .product(name: "AntdSdk", package: "antd-swift"),
            ]
        ),
    ]
)

For each example below, save the code as Sources/AutonomiExample/Main.swift, then run swift run.

Connect to antd

Follow Start the Local Daemon to run antd before connecting.

Expected output:

Store and retrieve data

Start antd in a write-enabled mode before you upload. The public Autonomi Network requires wallet and Ethereum Virtual Machine (EVM) payment configuration. A local development network created with ant dev start includes that configuration.

Expected output:

Type mappings

Autonomi type
Swift type

HealthStatus

Swift model type

PutResult

Swift model type

Raw data

Data

Error handling

antd 0.14.0 reports a valid address with no stored data as not found. Handle NotFoundError for this case. The client source is pinned independently to v0.12.1.

Output when the valid address is not stored:

Full API reference

For all available antd endpoints, see the REST API.

Last updated