Skip to content

Commit fe457a8

Browse files
committed
Update README
1 parent 7570a53 commit fe457a8

File tree

1 file changed

+23
-30
lines changed

1 file changed

+23
-30
lines changed

README.md

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Automatic Swift bindings generation for [`rust-lightning`](https://github.com/li
66

77
In order to use the automatically generated bindings, simply drag `*.xcframework` file into an Xcode project.
88

9-
The `*.xcframework` files are either available on
9+
The `*.xcframework` files are either available on
1010
the [Releases](https://github.com/lightningdevkit/ldk-swift/releases) page, or can be [compiled](#Compilation)
1111
from scratch.
1212

@@ -15,54 +15,60 @@ from scratch.
1515

1616
### Prerequisites
1717

18-
- A Mac with Xcode
18+
- A Mac with Xcode 13.2.1 or lower (this is because there is a bug with `cc` that prevents it from compiling for Mac Catalyst targets with clang 13)
1919
- Python3
2020
- Rust
21+
- `gnu-sed` (optional; but will cut your compile times significantly!)
2122

2223
For Rust specifically, there are a couple additional requirements that can be installed once the Rust toolchain
2324
is set up:
2425

2526
```shell
27+
rustup toolchain install nightly
2628
rustup target add aarch64-apple-darwin aarch64-apple-ios x86_64-apple-ios
27-
cargo install cargo-lipo
2829
cargo install cbindgen
2930
```
3031

3132
### Cloning Dependencies
3233

34+
Before you get started, make sure you `cd` to the `ldk-swift` directory.
35+
3336
In order to generate these bindings from scratch, you will need to clone two dependency repositories:
3437

35-
**rust-lightning**, (a specific branch built for bindings compatibility)
38+
**rust-lightning**, (a specific branch built for bindings compatibility)
3639
```shell
37-
git clone --branch 2021-03-java-bindings-base git@github.com:TheBlueMatt/rust-lightning.git
40+
git clone --branch 2021-03-java-bindings-base https://github.com/TheBlueMatt/rust-lightning bindings/artifacts/rust-lightning
3841
```
3942

4043
**ldk-c-bindings**
4144
```shell
42-
git clone git@github.com:lightningdevkit/ldk-c-bindings.git
45+
git clone https://github.com/lightningdevkit/ldk-c-bindings bindings/artifacts/ldk-c-bindings
4346
```
4447

48+
For compilation to work properly, make sure that both `rust-lightning` and `ldk-c-bindings` are present in `ldk-swift/bindings/artifacts`.
49+
4550
### Generating Rust-to-C-bindings
4651

4752
Now, navigate to the `ldk-c-bindings` directory and run the `genbindings.sh` script:
4853

4954
```shell
50-
cd /path/to/ldk-c-bindings
55+
pushd bindings/artifacts/ldk-c-bindings
5156
./genbindings.sh /path/to/rust-lightning true
57+
popd
5258
```
5359

5460
### Generating C-to-Swift-bindings
5561

5662
<details>
5763
<summary>If using Docker</summary>
5864

59-
If you're using Docker to generate the Swift bindings, navigate (if you're not already there from the
65+
If you're using Docker to generate the Swift bindings, navigate (if you're not already there from the
6066
previous step) to the `ldk-c-bindings` directory and open the file located here:
6167

6268
`/path/to/ldk-c-bindings/lightning-c-bindings/Cargo.toml`
6369

64-
In that file, you will see four lines specifying the `lightning`, `lightning-persister`, `lightning-invoice`, and
65-
`lightning-background-processor` dependencies. They will most likely show local paths to the `rust-lightning`
70+
In that file, you will see four lines specifying the `lightning`, `lightning-persister`, `lightning-invoice`, and
71+
`lightning-background-processor` dependencies. They will most likely show local paths to the `rust-lightning`
6672
folder due to the previous `genbindings.sh` step. As Docker won't have access to local paths,
6773
replace those lines with the following:
6874

@@ -73,48 +79,35 @@ lightning-invoice = { git = "https://github.com/thebluematt/rust-lightning", bra
7379
lightning-background-processor = { git = "https://github.com/thebluematt/rust-lightning", branch = "2021-03-java-bindings-base", default-features = false }
7480
```
7581

76-
You will note that the revision is unspecified and is currently just placeholder `xxx`s. To obtain the revision,
82+
You will note that the revision is unspecified and is currently just placeholder `xxx`s. To obtain the revision,
7783
just navigate to the just clone custom `rust-lightning` directory and run:
7884

7985
```shell
8086
cd /path/to/rust-lightning
8187
git rev-parse HEAD
8288
```
8389

84-
Take that commit hash and replace the `xxx` instances with it.
90+
Take that commit hash and replace the `xxx` instances with it.
8591
</details>
8692

8793
#### Generating the Swift files
8894

8995
To generate the Swift files, navigate to the `ldk-swift` repository and run the following:
9096

9197
```shell
92-
EXPORT LDK_SWIFT_GENERATOR_INPUT_HEADER_PATH="/path/to/ldk-c-bindings/lightning-c-bindings/include/lightning.h"
98+
export LDK_SWIFT_GENERATOR_INPUT_HEADER_PATH="$(pwd)/bindings/artifacts/ldk-c-bindings/lightning-c-bindings/include/lightning.h"
9399
python3 ./
94100
```
95101

96102
Now, the contents of the `bindings/LDK` folder will have been completely regenerated.
97103

98104
#### Generating the *.xcframework files
99105

100-
With the Swift files completely regenerated, you will need to make sure the Xcode projects that serve as bases
101-
for the `*.xcframework`s reference them correctly. So navigate here:
102-
103-
`path/to/ldk-swift/xcode`
104-
105-
and open the respective `*.xcodeproj` files located in the `LDKFramework` and `LDKFramework_Mac` directories.
106-
Do the following steps for _both_ projects:
107-
108-
1. Remove the `LDK` references in the Xcode file tree
109-
2. Drag the `path/to/ldk-swift/bindings/LDK` folder to that same location in the file tree
110-
3. Check `Copy items if needed` and pick `Create groups` in the dialog box
111-
112-
Next, navigate back to the `xcode` directory, and run the following scripts:
106+
With all the bindings generated, you will just have to run two commands to generate the xcframework:
113107

114108
```shell
115-
./compile_dependency_binaries.sh /path/to/ldk-c-bindings
116-
./build_framework.sh
109+
cd xcode
110+
./build_framework.sh
117111
```
118112

119-
Finally, navigate to `path/to/ldk-swift/bindings/bin`, and you should find multiple `*.xcframework` files
120-
waiting for you there.
113+
Once the script finishes running, you should see `LDKFramework.xcframework` in the `xcode/build` folder. Drag that into your project, and you're done!

0 commit comments

Comments
 (0)