Apache OpenDAL™ Swift Binding
A Swift binding for OpenDAL: access storage services through one API, backed by the Rust core.
New to the model behind the API? Read Concepts first — the shared storage semantics and path and operation concepts every binding expresses through its own native API.
This binding is unreleased and under active development. The API surface is minimal, breaking changes may happen without notice, and it is not suitable for production use. Contributions welcome.
Status
Experimental — unreleased. The binding depends on the C binding and must be built from source. It is not published to any package registry.
Capabilities
| Capability | Status |
|---|---|
| Blocking read | Supported |
| Blocking write | Supported |
Blocking existence check (blockingExists) | Supported |
Blocking delete (blockingDelete) | Supported |
Blocking directory creation (blockingCreateDirectory) | Supported on services with directory creation |
Blocking object copy (blockingCopy) | Supported on services with copy |
Blocking object rename (blockingRename) | Supported on services with rename |
Blocking stat (blockingStat) | Entry type, content length, and modification date when available |
Blocking list (blockingLister) | Nonrecursive cursor on services with listing |
| Async read/write | Not yet |
| Presigned URLs | Not yet |
The Operator class is the single entry point. It accepts a service scheme
string and a dictionary of string options, matching the same model as every
other OpenDAL binding. See Services for the full list of backends
and their configuration keys.
Installation
The package is not published to any registry. You must build the C dependency and reference the package by local path.
1. Build the C dependency
Run the following command from the repository root to build and stage the C header and static library for the Swift package.
make -C bindings/swift build-c
The C library builds in debug mode by default. To build an optimized C library,
set OPENDAL_C_PROFILE=release.
make -C bindings/swift build-c OPENDAL_C_PROFILE=release
You can combine this option with OPENDAL_FEATURES to enable additional
services. SwiftPM's
-c release selects the Swift build configuration separately. If you already
built your app, run swift package clean in the app directory before rebuilding
to link against the newly staged library.
2. Add a local path dependency
In your project's Package.swift, use the local path to bindings/swift/OpenDAL
in the checkout where you ran make build-c.
// swift-tools-version:5.7
import PackageDescription
let package = Package(
name: "MyTool",
dependencies: [
.package(path: "/path/to/opendal/bindings/swift/OpenDAL"),
],
targets: [
.target(name: "MyTool", dependencies: [
.product(name: "OpenDAL", package: "OpenDAL"),
]),
]
)
Replace /path/to/opendal with the absolute path to your local checkout.
Useful Links
- User guide: opendal.apache.org/docs/bindings/swift
- Services & configuration: /services
- Source:
bindings/swift/ - Contributing:
bindings/swift/CONTRIBUTING.md
Next steps
- Getting started — create an operator, write data, read it back.