Skip to content

Commit 05a6a21

Browse files
committed
Update README with usage and publishing instructions
1 parent ee56748 commit 05a6a21

File tree

1 file changed

+74
-1
lines changed

1 file changed

+74
-1
lines changed

README.md

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,76 @@
11
# bdk-swift
22

3-
A description of this package.
3+
This project builds a swift package that provides swift language bindings to the [`bdk`]
4+
library. The swift language bindings are created by the [`bdk-ffi`] project which is
5+
included as a git submodule of this repository.
6+
7+
## How to Use
8+
9+
To use the swift language bindings provided by the [`bdk-ffi`] project in your xcode iOS
10+
or MacOS project add this github repository and select one of the published versions. You
11+
may then import the `BitcoinDevKit` library. For example:
12+
13+
```swift
14+
import BitcoinDevKit
15+
16+
...
17+
18+
let desc = "wpkh([c258d2e4/84h/1h/0h]tpubDDYkZojQFQjht8Tm4jsS3iuEmKjTiEGjG6KnuFNKKJb5A6ZUCUZKdvLdSDWofKi4ToRCwb9poe1XdqfUnP4jaJjCB2Zwv11ZLgSbnZSNecE/0/*)"
19+
let config = DatabaseConfig.memory(junk: "")
20+
let wallet = try OfflineWallet.init(descriptor: desc, network: Network.regtest, databaseConfig: config)
21+
let address = wallet.getNewAddress()
22+
```
23+
24+
## How to Build and Publish
25+
26+
If you are a maintainer of this project or want to build and publish this project to your
27+
own repo use the following steps:
28+
29+
1. Clone this repo and init and update it's [`bdk-ffi`] submodule
30+
```shell
31+
git clone https://github.com/bitcoindevkit/bdk-swift
32+
git submodule update --init
33+
```
34+
35+
1. Follow the "General" `bdk-ffi` ["Getting Started (Developer)"] instructions.
36+
37+
1. Install the latest version of xcode, download and install the advanced tools.
38+
39+
1. Ensure Swift is installed
40+
41+
1. Install required targets
42+
```shell
43+
rustup target add aarch64-apple-ios x86_64-apple-ios
44+
```
45+
46+
1. Build [`bdk-ffi`] swift bindings and bdkFFI.xcframework.zip
47+
```shell
48+
./build.sh
49+
```
50+
51+
1. Update the `Package.swift` file with the new expected URL for the
52+
`bdkFFI.xcframework.zip` file and new hash as shown at the end of the build.sh script.
53+
For example:
54+
```swift
55+
.binaryTarget(
56+
name: "bdkFFI",
57+
url: "https://github.com/bitcoindevkit/bdk-swift/releases/download/0.1.3/bdkFFI.xcframework.zip",
58+
checksum: "c0b1e3ea09376b3f316d7d83575e1cd513fc4ad39ef8cf01120a3a1d7757fb97"),
59+
```
60+
1. Commit the changed `Package.swift` and tag it with the new version number.
61+
```shell
62+
git add Package.swift
63+
git commit -m "Bump version to 0.1.3"
64+
git tag 0.1.3 -m "Release 0.1.3"
65+
git push --tags
66+
```
67+
68+
1. Create a github release for your new tag.
69+
70+
1. Upload the newly created zip to the new github release.
71+
72+
1. Tests the new package in xcode.
73+
74+
[`bdk`]: https://github.com/bitcoindevkit/bdk
75+
[`bdk-ffi`]: https://github.com/bitcoindevkit/bdk-ffi
76+
["Getting Started (Developer)"]: https://github.com/bitcoindevkit/bdk-ffi#getting-started-developer

0 commit comments

Comments
 (0)