* Rename ls-sdk-bindings workspace member * Rename ls-sdk-core workspace member * Rename ls-sdk-react-native
3.8 KiB
Setting up a development environment
The Breez Liquid SDK React Native plugin consumes the underlying Breez Liquid SDK from the following sources:
- For iOS: The Breez Liquid SDK Swift bindings are integrated via CocoaPods.
- For Android: The Breez Liquid SDK Android bindings are integrated via Jitpack.
When developing, it can be useful to work with a locally built version of the Breez Liquid SDK instead of relying on what is published already on CocoaPods / Jitpack. To do this, you first need to build the Breez Liquid SDK bindings locally and then point the plugin to make use of the locally built Breez Liquid SDK bindings.
All the following commands can be run in the packages/react-native directory.
Prerequisites
Set the ANDROID_NDK_HOME env variable to your SDK home directory:
export ANDROID_NDK_HOME=<your android ndk directory>
To lint the result of the code generation ktlint, swiftformat and tslint need to be installed:
brew install kotlin ktlint swiftformat
yarn global add tslint typescript
On first usage you will need to run:
make init
Building the bindings
Then to build and copy the Kotlin, Swift and React Native bindings into the React Native package run:
make all
This will generate the following artifacts:
- iOS
ios/BreezLiquidSDKMapper.swiftios/BreezLiquidSDK.mios/BreezLiquidSDK.swiftios/bindings-swift/breez_liquid_sdkFFI.xcframeworkios/bindings-swift/Sources/BreezLiquidSDK/BreezLiquidSDK.swift
- Android
android/src/main/java/com/breezliquidsdk/breez_liquid_sdk.ktandroid/src/main/java/com/breezliquidsdk/BreezLiquidSDKMapper.ktandroid/src/main/java/com/breezliquidsdk/BreezLiquidSDKModule.ktandroid/src/main/jniLibs/arm64-v8a/libbreez_liquid_sdk_bindings.soandroid/src/main/jniLibs/armeabi-v7a/libbreez_liquid_sdk_bindings.soandroid/src/main/jniLibs/x86/libbreez_liquid_sdk_bindings.soandroid/src/main/jniLibs/x86_64/libbreez_liquid_sdk_bindings.so
- Typescript
src/index.ts
Building for one platform only
You can also build for Android or iOS only, in that case run:
make android react-native
or
make ios react-native
Using the locally built bindings
To use the locally built bindings instead of integrating them remotely, make the following changes:
- For iOS:
- Rename the podspec files in
packages/react-native/:- Rename
breez_liquid_sdk.podspectobreez_liquid_sdk.podspec.prod - Rename
BreezLiquidSDK.podspec.devtoBreezLiquidSDK.podspec
- Rename
- Rename the podspec files in
- For Android:
- Comment out the following line from the dependencies section in
packages/react-native/android/build.gradle:implementation("com.github.breez:breez-liquid-sdk:${getVersionFromNpmPackage()}") { exclude group:"net.java.dev.jna" }
- Comment out the following line from the dependencies section in
Reinstall the dependencies in the example project and run it. It will now use the locally built bindings.
Testing with the example app
To test locally built bindings in the example app, the npm dependencies need to be updated to use the local package.
In packages/react-native/example/package.json replace the current version with file:../:
"@breeztech/react-native-breez-liquid-sdk": "file:../",
Run the npm/yarn install to download dependences for both the react-native-breez-liquid-sdk package and the example app:
yarn bootstrap
Finally in the packages/react-native/example/ directory start either the iOS or Android app:
yarn android
or for iOS:
yarn ios
Troubleshooting
In case you get an error like:
java.lang.RuntimeException: Unable to load script. Make sure you're either running Metro (run 'npx react-native start') or that your bundle 'index.android.bundle' is packaged correctly for release.
Then manually run npx react-native start in the example directory and reload the app.