-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the React Native package build off of the generated bindings and …
…example project
- Loading branch information
Showing
101 changed files
with
21,619 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
node_modules | ||
**/.DS_Store | ||
# OSX | ||
# | ||
.DS_Store | ||
|
||
# XDE | ||
.expo/ | ||
|
||
# VSCode | ||
.vscode/ | ||
jsconfig.json | ||
|
||
# Xcode | ||
# | ||
build/ | ||
*.pbxuser | ||
!default.pbxuser | ||
*.mode1v3 | ||
!default.mode1v3 | ||
*.mode2v3 | ||
!default.mode2v3 | ||
*.perspectivev3 | ||
!default.perspectivev3 | ||
xcuserdata | ||
*.xccheckout | ||
*.moved-aside | ||
DerivedData | ||
*.hmap | ||
*.ipa | ||
*.xcuserstate | ||
project.xcworkspace | ||
|
||
# Android/IJ | ||
# | ||
.classpath | ||
.cxx | ||
.gradle | ||
.idea | ||
.project | ||
.settings | ||
local.properties | ||
android.iml | ||
|
||
# Cocoapods | ||
# | ||
breez_sdk.podspec.* | ||
BreezSDK.podspec | ||
example/ios/Pods | ||
|
||
# node.js | ||
# | ||
node_modules/ | ||
npm-debug.log | ||
yarn-debug.log | ||
yarn-error.log | ||
|
||
# BUCK | ||
buck-out/ | ||
\.buckd/ | ||
android/app/libs | ||
android/keystores/debug.keystore | ||
|
||
# Expo | ||
.expo/* | ||
|
||
# generated by bob | ||
lib/ | ||
|
||
# bindings (used for local development only) | ||
android/src/main/java/com/lssdk/ls_sdk.kt | ||
android/src/main/jniLibs | ||
ios/include/* | ||
ios/libs/* | ||
ios/bindings-swift/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
# Setting up a development environment | ||
|
||
The Liquid Swap SDK React Native plugin consumes the underlying Liquid Swap SDK from the following sources: | ||
|
||
- For iOS: The Liquid Swap SDK Swift bindings are integrated via CocoaPods. | ||
- For Android: The Liquid Swap SDK Android bindings are integrated via Jitpack. | ||
|
||
When developing, it can be useful to work with a locally built version of the Liquid Swap SDK instead of relying on what is published already on CocoaPods / Jitpack. | ||
To do this, you first need to build the Liquid Swap SDK bindings locally and then point the plugin to make use of the locally built Liquid Swap SDK bindings. | ||
|
||
## Prerequisites | ||
|
||
Set the ANDROID_NDK_HOME env variable to your SDK home folder: | ||
``` | ||
export ANDROID_NDK_HOME=<your android ndk directory> | ||
``` | ||
|
||
To lint the result of the code generation ktlint, swiftformat and tslint need to be installed: | ||
```bash | ||
brew install kotlin ktlint swiftformat | ||
yarn global add tslint typescript | ||
``` | ||
|
||
On first usage you will need to run: | ||
```bash | ||
make init | ||
``` | ||
|
||
## Generating the bridging code | ||
|
||
When there are changes to the UDL file in `lib/ls-sdk-binding/src` the React Native bridging code needs to be regenerated: | ||
```bash | ||
make react-native-codegen | ||
``` | ||
|
||
## Building the bindings | ||
|
||
Then to build and copy the Kotlin and Swift bindings into the React Native plugin: | ||
```bash | ||
make all | ||
``` | ||
|
||
This will generate the following artifacts: | ||
|
||
- iOS | ||
- `ios/LiquidSwapSDKMapper.swift` | ||
- `ios/LiquidSwapSDK.m` | ||
- `ios/LiquidSwapSDK.swift` | ||
- `ios/bindings-swift/ls_sdkFFI.xcframework` | ||
- `ios/bindings-swift/Sources/LiquidSwapSDK/LiquidSwapSDK.swift` | ||
- Android | ||
- `android/src/main/java/com/lssdk/ls_sdk.kt` | ||
- `android/src/main/java/com/lssdk/LiquidSwapSDKMapper.kt` | ||
- `android/src/main/java/com/lssdk/LiquidSwapSDKModule.kt` | ||
- `android/src/main/jniLibs/arm64-v8a/libls_sdk_bindings.so` | ||
- `android/src/main/jniLibs/armeabi-v7a/libls_sdk_bindings.so` | ||
- `android/src/main/jniLibs/x86/libls_sdk_bindings.so` | ||
- `android/src/main/jniLibs/x86_64/libls_sdk_bindings.so` | ||
- Typescript | ||
- `src/index.ts` | ||
|
||
## Using the locally built bindings | ||
|
||
To use the locally built bindings instead of integrating them remotely: | ||
|
||
- For iOS: | ||
- Rename `ls_sdk.podspec` to `ls_sdk.podspec.prod` | ||
- Rename `LiquidSwapSDK.podspec.dev` to `LiquidSwapSDK.podspec` | ||
- For Android: | ||
- Remove the following line from the dependencies section in `android/build.gradle`: | ||
- `implementation("com.github.breez:breez-sdk-liquid:${getVersionFromNpmPackage()}") { exclude group:"net.java.dev.jna" }` | ||
|
||
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 `example/package.json` replace the current version with `file:../`: | ||
```json | ||
"@breeztech/react-native-liquid-swap-sdk": "file:../", | ||
``` | ||
|
||
Run the npm/yarn install to download dependences for both the react-native-liquid-swap-sdk package and the example app: | ||
```bash | ||
yarn bootstrap | ||
``` | ||
|
||
Finally in `example/` start either the iOS or Android app: | ||
```bash | ||
yarn android | ||
``` | ||
or for iOS: | ||
```bash | ||
yarn ios | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 Breez | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
require "json" | ||
|
||
package = JSON.parse(File.read(File.join(__dir__, "package.json"))) | ||
|
||
Pod::Spec.new do |s| | ||
s.name = "LiquidSwapSDK" | ||
s.version = package["version"] | ||
s.summary = package["description"] | ||
s.homepage = package["homepage"] | ||
s.license = package["license"] | ||
s.authors = package["author"] | ||
|
||
s.platforms = { :ios => "11.0" } | ||
s.source = { :git => "https://github.com/breez/breez-sdk-liquid.git", :tag => "#{s.version}" } | ||
|
||
s.source_files = "ios/**/*.{h,m,mm,swift}" | ||
|
||
s.dependency "React-Core" | ||
s.vendored_frameworks = "ios/bindings-swift/ls_sdkFFI.xcframework" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
## Build | ||
|
||
### Prerequisites | ||
* set the ANDROID_NDK_HOME env variable to your sdk home folder | ||
``` | ||
export ANDROID_NDK_HOME=<your android ndk directory> | ||
``` | ||
|
||
### Building the plugin | ||
On first usage you will need to run: | ||
``` | ||
make init | ||
``` | ||
Then to generate the React Native code: | ||
``` | ||
make react-native | ||
``` | ||
|
||
### Generated artifacts | ||
* Android | ||
>* android/src/main/java/com/lssdk/LiquidSwapSDKMapper.kt | ||
>* android/src/main/java/com/lssdk/LiquidSwapSDKModule.kt | ||
* iOS | ||
>* ios/LiquidSwapSDKMapper.swift | ||
>* ios/LiquidSwapSDK.m | ||
>* ios/LiquidSwapSDK.swift | ||
* Typescript | ||
>* src/index.ts | ||
### Publish | ||
When publishing, make sure the following are updated: | ||
- Update the version number in `package.json`. | ||
- Set the published version of `@breeztech/react-native-liquid-swap-sdk` in `example/package.json`. | ||
|
||
Then login to npm: | ||
``` | ||
npm login --@scope=@breeztech | ||
``` | ||
Then publish: | ||
``` | ||
npm publish --access public | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import groovy.json.JsonSlurper | ||
|
||
def getVersionFromNpmPackage() { | ||
def inputFile = new File("$rootDir/../node_modules/@breeztech/react-native-liquid-swap-sdk/package.json") | ||
def packageJson = new JsonSlurper().parseText(inputFile.text) | ||
|
||
return packageJson["version"] | ||
} | ||
|
||
buildscript { | ||
repositories { | ||
google() | ||
mavenCentral() | ||
jcenter() | ||
} | ||
|
||
dependencies { | ||
classpath 'com.android.tools.build:gradle:3.5.3' | ||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21" | ||
} | ||
} | ||
|
||
apply plugin: 'com.android.library' | ||
apply plugin: 'kotlin-android' | ||
|
||
android { | ||
compileSdkVersion 34 | ||
defaultConfig { | ||
minSdkVersion 24 | ||
targetSdkVersion 34 | ||
versionCode 1 | ||
versionName "1.0" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
} | ||
} | ||
lintOptions { | ||
disable 'GradleCompatible' | ||
} | ||
} | ||
|
||
repositories { | ||
mavenLocal() | ||
maven { | ||
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm | ||
url("$rootDir/../node_modules/react-native/android") | ||
} | ||
google() | ||
mavenCentral { | ||
// We don't want to fetch react-native from Maven Central as there are | ||
// older versions over there. | ||
content { | ||
excludeGroup "com.facebook.react" | ||
} | ||
} | ||
jcenter() | ||
} | ||
|
||
allprojects { | ||
repositories { | ||
google() | ||
} | ||
} | ||
|
||
dependencies { | ||
//noinspection GradleDynamicVersion | ||
implementation "com.facebook.react:react-native:+" // From node_modules | ||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21" | ||
// Due to an issue with Jitpack (https://github.com/jitpack/jitpack.io/issues/5752) | ||
// the Android platform versions of JNA (specifically libjnadispatch.so) are missing when downloading the Liquid Swap SDK from Jitpack. | ||
// Therefore we ignore the version of JNA that comes with the Liquid Swap SDK from Jitpack | ||
// and manually add one that does include the necessary Android platform binaries. | ||
implementation("com.github.breez:breez-sdk-liquid:${getVersionFromNpmPackage()}") { exclude group:"net.java.dev.jna" } // remove for using locally built bindings during development | ||
implementation("net.java.dev.jna:jna:5.14.0@aar") | ||
} |
Binary file not shown.
5 changes: 5 additions & 0 deletions
5
lib/ls-sdk-react-native/android/gradle/wrapper/gradle-wrapper.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
Oops, something went wrong.