ffi-commons contains the Rust crate, UniFFI configuration, and helper tooling shared by the Kotlin, Swift, Python, and Ruby bindings. It is the source of truth for the exported taker API, data types, and generated foreign-language surfaces.
In normal use, you should build from the language package you are shipping. Each package owns the supported build scripts for staging native artifacts and regenerating bindings.
| Binding | Output directory | Runtime targets |
|---|---|---|
| coinswap-kotlin | ../coinswap-kotlin/lib/src/main/ |
Android arm64-v8a, armeabi-v7a, x86_64, JVM/Desktop |
| coinswap-swift | ../coinswap-swift/Sources/ and ../coinswap-swift/coinswap_ffi.xcframework |
iOS arm64, iOS simulator arm64/x86_64, macOS arm64/x86_64 |
| coinswap-python | ../coinswap-python/src/coinswap/ |
Linux x86_64/aarch64, macOS x86_64/arm64, Windows amd64 |
| coinswap-ruby | ../coinswap-ruby/ |
Linux x86_64/aarch64, macOS x86_64/arm64 |
The supported workflow is package-local:
- Kotlin builds are driven from
coinswap-kotlin/build-scripts/and then packaged with Gradle. - Swift builds are driven from
coinswap-swift/build-xcframework-dev.sh,build-xcframework-ci.sh, orbuild-xcframework.sh. - Python builds are driven from
coinswap-python/build-scripts/and then packaged withpython -m build. - Ruby builds are driven from
coinswap-ruby/build-scripts/.
This keeps target selection, output layout, and packaging concerns next to the language consumer instead of centralizing them in a single monolithic script.
Work directly in ffi-commons when you are changing the exported Rust API, UniFFI schema, or shared build logic.
- Rust 1.75.0 or newer.
cargo run --bin uniffi-bindgenavailable from this workspace.- Platform toolchains for the targets you intend to build.
cd ffi-commons
rustup target add x86_64-unknown-linux-gnu
cargo build --package coinswap-ffi --profile release-smaller --target x86_64-unknown-linux-gnucd ffi-commons
cargo run --bin uniffi-bindgen generate \
--library ./target/x86_64-unknown-linux-gnu/release-smaller/libcoinswap_ffi.so \
--language python \
--out-dir ../coinswap-python/src/coinswap/native/linux-x86_64 \
--no-formatThe package-local scripts wrap these steps and place outputs in the paths expected by each binding.
- Minimum SDK: 24.
- Primary ABIs:
arm64-v8a,armeabi-v7a,x86_64. - Requires Android NDK for native builds.
- Swift packaging targets iOS 13+ and macOS 10.15+.
- XCFramework builds combine device and simulator slices for the Apple consumers.
- Packaged native resources are staged under
src/coinswap/native/<platform>/. - The Python package metadata declares Linux, macOS, and Windows native resources.
- Generated Ruby bindings live at the package root as
coinswap.rb. - Native libraries are staged next to the binding for direct FFI loading.
ffi-docker-setup provisions the local regtest environment used by the live integration flows:
cd ffi-commons
./ffi-docker-setup setup
./ffi-docker-setup start 4
./ffi-docker-setup stopstart 4 brings up Bitcoin Core, Tor, and four maker services for end-to-end taker testing.
- Issues: GitHub Issues
- Discussions: GitHub Discussions