Skip to content

Swift and dart bindings tests in ci#1706

Merged
thesimplekid merged 16 commits into
cashubtc:mainfrom
crodas:feature/bindings
Mar 29, 2026
Merged

Swift and dart bindings tests in ci#1706
thesimplekid merged 16 commits into
cashubtc:mainfrom
crodas:feature/bindings

Conversation

@crodas
Copy link
Copy Markdown
Collaborator

@crodas crodas commented Mar 6, 2026

Description

Prototype to have a monorepo for all the bindings


Closes: #1539, #1670

Notes to the reviewers


Suggested CHANGELOG Updates

CHANGED

ADDED

REMOVED

FIXED


Checklist

@github-project-automation github-project-automation Bot moved this to Backlog in CDK Mar 6, 2026
Copy link
Copy Markdown
Collaborator

@thesimplekid thesimplekid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. I think this is generally in the right direction though I didn't try to run anything.

Comment thread bindings/swift/generate-bindings.sh Outdated
Comment thread bindings/dart/flutter_example/lib/main.dart Outdated
Comment thread bindings/swift/Sources/Cdk/CashuDevKit.swift Outdated
Comment thread crates/cdk-ffi/Cargo.toml Outdated
Comment thread bindings/dart/generate-bindings.sh
Comment thread bindings/swift/generate-bindings.sh Outdated
Comment thread bindings/README.md Outdated
Comment thread crates/cdk-ffi/src/database.rs
Comment thread bindings/dart/rust/uniffi-bindgen.rs Outdated
Comment thread bindings/dart/rust/Cargo.toml Outdated
@crodas crodas force-pushed the feature/bindings branch 7 times, most recently from ec78b29 to 6199ed5 Compare March 10, 2026 14:53
@thesimplekid
Copy link
Copy Markdown
Collaborator

I notice the flake.lock is not changed after adding the dart overlay. This could be what is causing the rate limiting as this needs to be updated. nix flake lock should be run and the new lock file committed.

Comment thread bindings/dart/lib/src/generated/cdk_ffi.dart Outdated
Comment thread Package.swift Outdated
@crodas crodas force-pushed the feature/bindings branch from 6199ed5 to fc1ff7f Compare March 13, 2026 00:20
@thesimplekid thesimplekid mentioned this pull request Mar 13, 2026
2 tasks
@crodas crodas force-pushed the feature/bindings branch 3 times, most recently from 8df4da8 to 67b7988 Compare March 16, 2026 22:33
@crodas crodas self-assigned this Mar 16, 2026
@crodas crodas force-pushed the feature/bindings branch 8 times, most recently from 497e283 to 2adf0f4 Compare March 18, 2026 14:44
Comment thread bindings/swift/Tests/CdkTests.swift Outdated
@crodas crodas force-pushed the feature/bindings branch from 3ed1270 to 9e53728 Compare March 28, 2026 13:00
@thesimplekid
Copy link
Copy Markdown
Collaborator

Should fix the swift. #1784

@crodas crodas force-pushed the feature/bindings branch from 18be5d3 to 96e4e6f Compare March 28, 2026 15:09
crodas added 10 commits March 28, 2026 14:53
Introduce Dart/Flutter bindings generated via uniffi-dart, including:
- Flutter example wallet app with mint, send, and receive flows
- WalletStore enum (Sqlite/Postgres/Custom) replacing separate constructors,
  allowing both built-in Rust backends and foreign callback implementations
through a single `new()` constructor
- Justfile targets for building and running Dart bindings
- Post-generation patches for uniffi-dart codegen issues
- Add Swift binding generation via UniFFI for iOS, iOS Simulator, and macOS
- Include generate-bindings.sh script that builds universal XCFramework with
  support for aarch64-apple-ios, aarch64-apple-ios-sim, and aarch64-apple-darwin targets
- Add Swift wrapper (CashuDevKit.swift) generated from cdk-ffi crate
- Add Swift example project demonstrating wallet creation, minting, melting,
  and multi-mint wallet usage
- Include Info.plist resources for iOS, iOS Simulator, and macOS frameworks
- Add UniFFI bindgen configuration (uniffi.toml) and Swift bindgen binary
- Update justfile with swift-bindings and swift-example tasks
- Update Dart bindings: regenerate FFI bindings, add generate-bindings.sh,
  update flutter_example dependencies
- Bump cdk-ffi uniffi dependency to version 0.29
- Consolidate uniffi version (0.30) in workspace root Cargo.toml
- Replace per-crate version pins with workspace = true in cdk-ffi,
  cdk-ffi-swift, and cdk-ffi-dart
- Apply rustfmt formatting to dart bindings codegen and FFI sources
- Update Cargo.lock.msrv with resolved dependency versions
- Remove the Flutter example app and Swift example app
- Add Dart unit tests (wallet_test.dart) and Swift tests (CdkTests.swift) that
  verify wallet initialization, zero balance, and mint flow against
testnut.cashu.space
- Add CI jobs for Dart and Swift binding tests on self-hosted/macOS runners
- Add nix `bindings` devShell with Dart SDK, OpenSSL, and stable Rust toolchain
  (including Apple cross-compile targets)
- Fix Dart build hook to forward full parent environment to cargo and extract
  OpenSSL paths from NIX_CFLAGS_COMPILE/NIX_LDFLAGS as fallback
- Update justfile: replace `example-dart`/`example-swift` with
  `test-dart`/`test-swift` recipes
…ndoring

Use the stable toolchain (craneLib) instead of MSRV toolchain for vendoring
dependencies, since cargo 1.85.0 does not support --exclude-lockfile needed by
crane to package git dependencies like uniffi-dart.

Also exclude cdk-ffi-dart and cdk-ffi-swift from MSRV workspace builds as their
dependencies (uniffi-dart) require a newer Rust toolchain.
uniffi-dart generates the Record class as P2pkSigningKey (camelCase) but
references it as P2PKSigningKey in callback interface methods and
sequence/optional converters, causing Dart compilation errors.

Normalize all occurrences to P2pkSigningKey in the post-generation patch.
The swift test runner requires a Package.swift at the repo root, but it depends
on build artifacts from the XCFramework generation step. Generate it in the
pipeline rather than committing it to the repo.
@crodas crodas force-pushed the feature/bindings branch from 96e4e6f to f444745 Compare March 28, 2026 17:53
@crodas crodas force-pushed the feature/bindings branch from f444745 to c7c76f8 Compare March 28, 2026 18:28
crodas added 3 commits March 28, 2026 16:01
Add WalletStore factory functions (sqliteWalletStore, postgresWalletStore,
customWalletStore) so downstream consumers don't need to construct enum
variants directly. Document the UniFFI limitation that requires the enum
wrapper instead of accepting trait objects as parameters.

Document all five uniffi-dart codegen patches in patch_generated() to explain
what each fixes and why it's needed.
@crodas crodas marked this pull request as ready for review March 28, 2026 20:25
@thesimplekid thesimplekid changed the title Bindings Swift and dart bindings tests in ci Mar 29, 2026
Copy link
Copy Markdown
Collaborator

@thesimplekid thesimplekid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this. I think this is good to merge now. I did leave some more comment where I think we can improve this a bit more but lets do that as a follow up to keep things moving.

@crodas If you could look at the comments and make issues out of the ones that make sense so they can addresses that would be great.

Comment thread bindings/dart/rust/rust-toolchain.toml
Comment thread bindings/dart/rust/rust-toolchain.toml
Comment thread bindings/swift/rust/rust-toolchain.toml
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im not sure we need the full XC framework and IOS stuff since we're not releasing from here and only want to run a smoke test of the building and running tests of swift bindings on macos runner.

Comment thread bindings/swift/generate-bindings.sh
Comment thread bindings/swift/generate-bindings.sh
Comment thread bindings/swift/Tests/CdkTests.swift
Comment thread .github/workflows/ci.yml
Comment thread .github/workflows/ci.yml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants