Official Swift SDK for AIngle - the ultra-light distributed ledger for IoT devices.
Add to your Package.swift:
dependencies: [
.package(url: "https://github.com/ApiliumCode/aingle-sdk-swift.git", from: "0.1.0")
]Or in Xcode: File → Add Packages → Enter URL:
https://github.com/ApiliumCode/aingle-sdk-swift.git
import AIngleSDK
// Create client
let client = AIngleClient()
// Create an entry
let hash = try await client.createEntry([
"type": "sensor_reading",
"value": 23.5,
"unit": "celsius"
])
print("Created entry: \(hash)")
// Retrieve an entry
if let entry = try await client.getEntry(hash: hash) {
print("Entry: \(entry)")
}
// Get node info
let info = try await client.getNodeInfo()
print("Node version: \(info.version)")import AIngleSDK
let client = AIngleClient()
// Subscribe to updates
for await entry in client.subscribe() {
print("New entry: \(entry.hash)")
}| Method | Description |
|---|---|
createEntry(_:) |
Create a new entry |
getEntry(hash:) |
Retrieve an entry by hash |
getNodeInfo() |
Get node information |
subscribe() |
Subscribe to real-time updates |
close() |
Close the client |
let config = AIngleClientConfig(
nodeURL: URL(string: "http://localhost:8080")!,
wsURL: URL(string: "ws://localhost:8081")!,
timeout: 30,
debug: false
)
let client = AIngleClient(config: config)| Platform | Minimum Version |
|---|---|
| iOS | 15.0 |
| macOS | 12.0 |
| tvOS | 15.0 |
| watchOS | 8.0 |
# Build
swift build
# Run tests
swift test
# Generate Xcode project
swift package generate-xcodeprojApache-2.0 - see LICENSE