Swift bindings for CDK, a Cashu protocol implementation.
Add to your Package.swift:
dependencies: [
.package(url: "https://github.com/cashubtc/cdk-swift", from: "0.16.0"),
]Then add "Cdk" as a dependency of your target:
.target(name: "MyApp", dependencies: [
.product(name: "Cdk", package: "cdk-swift"),
]),- Open your project in Xcode
- Go to File > Add Package Dependencies...
- Enter
https://github.com/cashubtc/cdk-swift - Select the version rule (e.g. "Up to Next Major Version" from
0.16.0) - Click Add Package
- Select the
Cdklibrary and add it to your target
- iOS 14+ / macOS 13+
- Swift 5.9+
import Cdk
// 1. Create a wallet
let wallet = try Wallet(
mintUrl: "https://mint.example.com",
unit: .sat,
mnemonic: try generateMnemonic(),
store: .sqlite(path: "wallet.sqlite"),
config: WalletConfig(targetProofCount: nil)
)
// 2. Request a mint quote
let quote = try await wallet.mintQuote(
paymentMethod: .bolt11,
amount: Amount(value: 1000),
description: nil,
extra: nil
)
print("Pay this invoice: \(quote.request)")
// 3. After paying the invoice, mint ecash
let proofs = try await wallet.mint(
quoteId: quote.id,
amountSplitTarget: .none,
spendingConditions: nil
)
// 4. Check balance
let balance = try await wallet.totalBalance()
print("Balance: \(balance.value) sats")The Swift package uses a pre-built CashuDevKitFFI.xcframework downloaded automatically via SPM from GitHub releases.
Supported platforms:
| Platform | Architecture |
|---|---|
| iOS | arm64 |
| iOS Simulator | arm64, x86_64 |
| macOS | arm64, x86_64 |
just test-swiftThe swift-publish.yml workflow (in the CDK monorepo) builds the XCFramework,
generates Swift sources, syncs everything to cdk-swift, and creates a tagged
release. The following secrets and variables must be configured in the CDK
monorepo repository settings (Settings > Secrets and variables > Actions).
| Name | Purpose |
|---|---|
FFI_DEPLOY_KEY |
Personal access token (PAT) with repo scope on the FFI target repos (cdk-dart, cdk-kotlin, cdk-swift). Used to clone, push, and create releases. Shared across all FFI publish workflows. |
- Go to GitHub > Settings > Developer settings > Personal access tokens > Fine-grained tokens.
- Create a token scoped to the
cdk-dart,cdk-kotlin, andcdk-swiftrepositories with Contents (read/write) and Metadata (read) permissions. - Add it as a repository secret named
FFI_DEPLOY_KEYin the monorepo.
| Name | Purpose | Example |
|---|---|---|
CDK_SWIFT_REPO |
Owner/repo of the target Swift package repository. | cashubtc/cdk-swift |
Set this under Settings > Secrets and variables > Actions > Variables.