Minimal Swift bindings for Iroh blob storage.
- Swift 6.2+
- iOS 26+ / macOS 26+
- Xcode 26+
Add to your Package.swift:
dependencies: [
.package(url: "https://github.com/arkavo-org/iroh-swift.git", from: "0.1.0")
]Then add IrohSwift to your target dependencies:
.target(
name: "YourApp",
dependencies: ["IrohSwift"]
)import IrohSwift
// Create a node (uses Application Support for storage by default)
let node = try await IrohNode()
// Store data and get a shareable ticket
let data = "Hello, Iroh!".data(using: .utf8)!
let ticket = try await node.put(data)
print("Ticket: \(ticket)")
// Retrieve data using a ticket
let retrieved = try await node.get(ticket: ticket)
print("Data: \(String(data: retrieved, encoding: .utf8)!)")import IrohSwift
// Custom storage path and relay settings
let config = IrohConfig(
storagePath: myCustomURL, // nil = Application Support/iroh
relayEnabled: true // n0 public relays (default: true)
)
let node = try await IrohNode(config: config)An actor providing thread-safe access to Iroh blob operations.
| Method | Description |
|---|---|
init(config:) |
Create a new node with optional configuration |
put(_:) |
Store data and return a shareable ticket |
get(ticket:) |
Download data using a ticket |
| Property | Type | Default | Description |
|---|---|---|---|
storagePath |
URL |
Application Support/iroh | Blob storage directory |
relayEnabled |
Bool |
true |
Use n0 public relay servers |
| Case | Description |
|---|---|
nodeCreationFailed |
Failed to create the Iroh node |
putFailed |
Failed to store data |
getFailed |
Failed to retrieve data |
invalidTicket |
Invalid ticket format |
- Rust toolchain (
rustup) - Xcode 26+
./scripts/build-xcframework.shThis builds for:
aarch64-apple-ios(iOS device)aarch64-apple-ios-sim(iOS Simulator)aarch64-apple-darwin(macOS)
swift test- Rust FFI: Manual C ABI using
cbindgenfor header generation - Swift Actor: Thread-safe wrapper with async/await
- Storage: Persistent
FsStorein Application Support (excluded from iCloud backup) - Networking: n0 public relays enabled by default for NAT traversal
| iroh-swift | iroh | iroh-blobs |
|---|---|---|
| 0.1.x | 0.95 | 0.97 |
Apache-2.0 OR MIT