@bennyblader/ddk-rn
v0.3.33
Published
dlcdevkit bindings for react-native
Readme
@bennyblader/ddk-rn
React Native bindings for the DLC Dev Kit (DDK) - UniFFI-based native bindings for React Native applications.
Installation
npm install @bennyblader/ddk-rn
# or
pnpm add @bennyblader/ddk-rnQuick Start
import { version, createFundTxLockingScript } from '@bennyblader/ddk-rn';
console.log(`DDK Version: ${version()}`);For complete API documentation, see the main README.
Development
Prerequisites
- Node.js >= 14
- Rust >= 1.70
- pnpm
- UniFFI React Native:
npm install -g uniffi-bindgen-react-native - iOS: Xcode 14+, CocoaPods
- Android: Android Studio, NDK
Building from Source
# Install dependencies
pnpm install
# Generate all bindings and build native libraries
just uniffi
# Note: After building, manually fix the include path in cpp/bennyblader-ddk-rn.cpp
# Change: #include "/ddk_ffi.hpp"
# To: #include "ddk_ffi.hpp"Just Commands
# Complete build (generates bindings + builds iOS/Android)
just uniffi
# Generate JSI bindings only
just uniffi-jsi
# Generate TurboModule specifications
just uniffi-turbo
# Build iOS libraries
just build-ios
# Build Android libraries
just build-android
# Setup example app
just example
# iOS example setup
just example-ios
# Android example build
just example-android
# Clean all generated files
just clean
# Release new version
just release
# Create release archives
just release-archivesProject Structure
ddk-rn/
├── src/ # Generated TypeScript bindings
│ ├── index.tsx # Main entry point (generated)
│ └── ddk_ffi*.ts # Type definitions (generated)
├── cpp/ # Generated C++ JSI bindings
│ ├── ddk_ffi.hpp # C++ header (generated)
│ ├── ddk_ffi.cpp # C++ implementation (generated)
│ └── *.cpp/.h # TurboModule files (generated)
├── ios/ # iOS native module
│ ├── DdkRn.xcframework/ # iOS framework (generated)
│ └── *.swift/.m # iOS bridge code
├── android/ # Android native module
│ └── src/main/
│ ├── java/ # Kotlin/Java bridge code
│ └── jniLibs/ # Native libraries (generated)
├── example/ # Example React Native app
├── scripts/ # Build and release scripts
└── ubrn.config.yaml # UniFFI React Native configurationPlatform Support
| Platform | Architecture | Status | | ------------- | ------------ | ------------ | | iOS | ARM64 | ✅ Supported | | iOS Simulator | x64/ARM64 | ✅ Supported | | Android | ARM64-v8a | ✅ Supported | | Android | ARMv7 | ✅ Supported | | Android | x86_64 | ✅ Supported |
Building the Example App
iOS
# Install iOS dependencies with new architecture
just example-ios
# Run the app
cd example
npx react-native run-iosAndroid
# Build Android app
just example-android
# Run the app
cd example
npx react-native run-androidRelease Process
To release a new version:
just releaseThis will:
- Build all native bindings
- Run tests
- Update version
- Create release commit and tag
- Push to GitHub
- Publish to npm
API Compatibility
The React Native bindings maintain 100% API compatibility with the UniFFI definitions. All functions are generated directly from the UDL file ensuring consistency across platforms.
Known Issues
Manual Include Path Fix: After running
just uniffi, you must manually fix the include path incpp/bennyblader-ddk-rn.cpp:- Change:
#include "/ddk_ffi.hpp" - To:
#include "ddk_ffi.hpp"
- Change:
New Architecture: The library requires React Native's new architecture to be enabled:
- iOS: Set
RCT_NEW_ARCH_ENABLED=1 - Android: Set
newArchEnabled=trueingradle.properties
- iOS: Set
Troubleshooting
iOS Build Issues
If you encounter build issues on iOS:
cd example/ios
pod deintegrate
pod installAndroid Build Issues
Clean and rebuild Android:
cd example/android
./gradlew clean
./gradlew buildMissing Bindings
If bindings are missing, regenerate them:
just clean
just uniffiLicense
MIT
