Move build-local-swift.sh into bdk-swift directory, fix README
This commit is contained in:
@@ -3,6 +3,12 @@
|
||||
This project builds a Swift package that provides [Swift] language bindings for the
|
||||
[`bdk`] library. The Swift language bindings are created by the [`bdk-ffi`] project which is included as a module of this repository.
|
||||
|
||||
Supported target platforms are:
|
||||
|
||||
- MacOS, X86_64 and M1 (aarch64)
|
||||
- iOS, iPhones (aarch64)
|
||||
- iOS simulator, X86_64 and M1 (aarch64)
|
||||
|
||||
## How to Use
|
||||
|
||||
To use the Swift language bindings for [`bdk`] in your [Xcode] iOS or MacOS project add
|
||||
@@ -17,7 +23,9 @@ import BitcoinDevKit
|
||||
|
||||
```
|
||||
|
||||
Note: the Swift Package Manager package for `bdk-swift` is located in it's own repository (https://github.com/bitcoindevkit/bdk-swift), and that is where releases are created for it. But the code that generates the bindings is located in the https://github.com/bitcoindevkit/bdk-ffi repo in the `bdk-swift/` directory.
|
||||
Swift Package Manager releases for `bdk-swift` are published to a separate repository (https://github.com/bitcoindevkit/bdk-swift), and that is where the releases are created for it.
|
||||
|
||||
The `bdk-swift/build-local-swift.sh` script can be used instead to create a version of the project for local testing.
|
||||
|
||||
### How to test
|
||||
|
||||
@@ -27,19 +35,18 @@ swift test
|
||||
|
||||
### Example Projects
|
||||
|
||||
* TBD
|
||||
* [BdkSwiftSample](https://github.com/futurepaul/BdkSwiftSample), iOS
|
||||
|
||||
## How to Build and Publish
|
||||
|
||||
If you are a maintainer of this project or want to build and publish this project to your
|
||||
own Github repository use the following steps:
|
||||
|
||||
If you are a maintainer of this project or want to build and publish this project to your
|
||||
own Github repository use the following steps:
|
||||
|
||||
1. If it doesn't already exist, create a new `release/0.MINOR` branch from the `master` branch.
|
||||
2. Add a tag `v0.MINOR.0`.
|
||||
3. Run the `publish-spm` workflow on Github from the `bdk-swift` repo for version `0.MINOR.0`.
|
||||
2. Add a tag `v0.MINOR.PATCH`.
|
||||
3. Run the `publish-spm` workflow on Github from the `bdk-swift` repo for version `0.MINOR.PATCH`.
|
||||
|
||||
[Swift]: https://developer.apple.com/swift/
|
||||
[Xcode]: https://developer.apple.com/documentation/Xcode
|
||||
[`bdk`]: https://github.com/bitcoindevkit/bdk
|
||||
[`bdk-ffi`]: https://github.com/bitcoindevkit/bdk-ffi
|
||||
|
||||
41
bdk-swift/build-local-swift.sh
Executable file
41
bdk-swift/build-local-swift.sh
Executable file
@@ -0,0 +1,41 @@
|
||||
#!/bin/bash
|
||||
# This script builds local swift-bdk Swift language bindings and corresponding bdkFFI.xcframework.
|
||||
# The results of this script can be used for locally testing your SPM package adding a local package
|
||||
# to your application pointing at the bdk-swift directory.
|
||||
#
|
||||
# Run the script from the repo root directory, ie: ./bdk-swift/build-local-swift.sh
|
||||
|
||||
rustup install nightly-x86_64-apple-darwin
|
||||
rustup component add rust-src --toolchain nightly-x86_64-apple-darwin
|
||||
rustup target add aarch64-apple-ios x86_64-apple-ios
|
||||
rustup target add aarch64-apple-ios-sim --toolchain nightly
|
||||
rustup target add aarch64-apple-darwin x86_64-apple-darwin
|
||||
|
||||
pushd bdk-ffi
|
||||
mkdir -p Sources/BitcoinDevKit
|
||||
cargo run --package bdk-ffi-bindgen -- --language swift --out-dir ../bdk-swift/Sources/BitcoinDevKit
|
||||
popd
|
||||
|
||||
cargo build --package bdk-ffi --profile release-smaller --target x86_64-apple-darwin
|
||||
cargo build --package bdk-ffi --profile release-smaller --target aarch64-apple-darwin
|
||||
cargo build --package bdk-ffi --profile release-smaller --target x86_64-apple-ios
|
||||
cargo build --package bdk-ffi --profile release-smaller --target aarch64-apple-ios
|
||||
cargo +nightly build --package bdk-ffi --release -Z build-std --target aarch64-apple-ios-sim
|
||||
|
||||
mkdir -p target/lipo-ios-sim/release-smaller
|
||||
lipo target/aarch64-apple-ios-sim/release/libbdkffi.a target/x86_64-apple-ios/release-smaller/libbdkffi.a -create -output target/lipo-ios-sim/release-smaller/libbdkffi.a
|
||||
mkdir -p target/lipo-macos/release-smaller
|
||||
lipo target/aarch64-apple-darwin/release-smaller/libbdkffi.a target/x86_64-apple-darwin/release-smaller/libbdkffi.a -create -output target/lipo-macos/release-smaller/libbdkffi.a
|
||||
|
||||
pushd bdk-swift
|
||||
mv Sources/BitcoinDevKit/bdk.swift Sources/BitcoinDevKit/BitcoinDevKit.swift
|
||||
cp Sources/BitcoinDevKit/bdkFFI.h bdkFFI.xcframework/ios-arm64/bdkFFI.framework/Headers
|
||||
cp Sources/BitcoinDevKit/bdkFFI.h bdkFFI.xcframework/ios-arm64_x86_64-simulator/bdkFFI.framework/Headers
|
||||
cp Sources/BitcoinDevKit/bdkFFI.h bdkFFI.xcframework/macos-arm64_x86_64/bdkFFI.framework/Headers
|
||||
cp ../target/aarch64-apple-ios/release-smaller/libbdkffi.a bdkFFI.xcframework/ios-arm64/bdkFFI.framework/bdkFFI
|
||||
cp ../target/lipo-ios-sim/release-smaller/libbdkffi.a bdkFFI.xcframework/ios-arm64_x86_64-simulator/bdkFFI.framework/bdkFFI
|
||||
cp ../target/lipo-macos/release-smaller/libbdkffi.a bdkFFI.xcframework/macos-arm64_x86_64/bdkFFI.framework/bdkFFI
|
||||
rm Sources/BitcoinDevKit/bdkFFI.h
|
||||
rm Sources/BitcoinDevKit/bdkFFI.modulemap
|
||||
#rm bdkFFI.xcframework.zip || true
|
||||
#zip -9 -r bdkFFI.xcframework.zip bdkFFI.xcframework
|
||||
Reference in New Issue
Block a user