Skip to content

Commit 1f55493

Browse files
committed
Parameterize LDK_DIRECTORY
# Conflicts: # xcode/LDK/LDKFramework.xcodeproj/project.pbxproj
1 parent fe457a8 commit 1f55493

File tree

4 files changed

+33
-11
lines changed

4 files changed

+33
-11
lines changed

README.md

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,28 +31,26 @@ cargo install cbindgen
3131

3232
### Cloning Dependencies
3333

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

3836
**rust-lightning**, (a specific branch built for bindings compatibility)
3937
```shell
40-
git clone --branch 2021-03-java-bindings-base https://github.com/TheBlueMatt/rust-lightning bindings/artifacts/rust-lightning
38+
git clone --branch 2021-03-java-bindings-base https://github.com/TheBlueMatt/rust-lightning /path/to/rust-lightning
4139
```
4240

4341
**ldk-c-bindings**
4442
```shell
45-
git clone https://github.com/lightningdevkit/ldk-c-bindings bindings/artifacts/ldk-c-bindings
43+
git clone https://github.com/lightningdevkit/ldk-c-bindings /path/to/ldk-c-bindings
4644
```
4745

48-
For compilation to work properly, make sure that both `rust-lightning` and `ldk-c-bindings` are present in `ldk-swift/bindings/artifacts`.
46+
Take note of where you clone these directories, it's best you save the absolute path somewhere handy for the rest of the remaining steps.
4947

5048
### Generating Rust-to-C-bindings
5149

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

5452
```shell
55-
pushd bindings/artifacts/ldk-c-bindings
53+
pushd path/to/ldk-c-bindings
5654
./genbindings.sh /path/to/rust-lightning true
5755
popd
5856
```
@@ -95,12 +93,25 @@ Take that commit hash and replace the `xxx` instances with it.
9593
To generate the Swift files, navigate to the `ldk-swift` repository and run the following:
9694

9795
```shell
98-
export LDK_SWIFT_GENERATOR_INPUT_HEADER_PATH="$(pwd)/bindings/artifacts/ldk-c-bindings/lightning-c-bindings/include/lightning.h"
96+
export LDK_SWIFT_GENERATOR_INPUT_HEADER_PATH="$(pwd)/path/to/ldk-c-bindings/lightning-c-bindings/include/lightning.h"
9997
python3 ./
10098
```
10199

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

102+
### Configuring Xcode for Framework Compilation
103+
Go to the `xcode` folder and open `LDKFramework.xcworkspace`.
104+
105+
Then, navigate to the "LDKFramework" project and click on the LDKFramework target:
106+
![](https://user-images.githubusercontent.com/5944973/175575527-97073a18-76fc-4ab0-928f-d40ac643e607.png)
107+
108+
Search for "LDK_DIRECTORY":
109+
![](https://user-images.githubusercontent.com/5944973/175575621-38224096-4baa-44cc-8345-ec2b871fcbe6.png)
110+
111+
Here, enter the absolute path you to ldk-c-bindings you saved above.
112+
113+
Now, do the same for the "LDKFramework_Mac" target.
114+
104115
#### Generating the *.xcframework files
105116

106117
With all the bindings generated, you will just have to run two commands to generate the xcframework:

xcode/DirectBindingsApp/DirectBindingsApp.xcodeproj/project.pbxproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1853,7 +1853,7 @@
18531853
);
18541854
runOnlyForDeploymentPostprocessing = 0;
18551855
shellPath = /bin/sh;
1856-
shellScript = "LDK_DIRECTORY=${PROJECT_DIR}/../../bindings/artifacts/ldk-c-bindings # directory to compile the C bindings in\nC_BINDINGS_SOURCE_DIRECTORY=\"$(cd ${LDK_DIRECTORY}; pwd)/lightning-c-bindings\"\n\nmkdir -p $PROJECT_DIR/headers\ncp \"${C_BINDINGS_SOURCE_DIRECTORY}/include/\"*.h $PROJECT_DIR/headers\ncp \"${LDK_DIRECTORY}/ldk-net/ldk_net.\"{c,h} $PROJECT_DIR/headers\n";
1856+
shellScript = "C_BINDINGS_SOURCE_DIRECTORY=\"$(cd ${LDK_DIRECTORY}; pwd)/lightning-c-bindings\"\n\nmkdir -p $PROJECT_DIR/headers\ncp \"${C_BINDINGS_SOURCE_DIRECTORY}/include/\"*.h $PROJECT_DIR/headers\ncp \"${LDK_DIRECTORY}/ldk-net/ldk_net.\"{c,h} $PROJECT_DIR/headers\n";
18571857
};
18581858
/* End PBXShellScriptBuildPhase section */
18591859

@@ -2734,6 +2734,7 @@
27342734
HEADER_SEARCH_PATHS = "$(PROJECT_DIR)";
27352735
INFOPLIST_FILE = DirectBindingsApp/Info.plist;
27362736
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
2737+
LDK_DIRECTORY = "${PROJECT_DIR}/../../bindings/artifacts/ldk-c-bindings";
27372738
LD_RUNPATH_SEARCH_PATHS = (
27382739
"$(inherited)",
27392740
"@executable_path/Frameworks",
@@ -2764,6 +2765,7 @@
27642765
HEADER_SEARCH_PATHS = "$(PROJECT_DIR)";
27652766
INFOPLIST_FILE = DirectBindingsApp/Info.plist;
27662767
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
2768+
LDK_DIRECTORY = "${PROJECT_DIR}/../../bindings/artifacts/ldk-c-bindings";
27672769
LD_RUNPATH_SEARCH_PATHS = (
27682770
"$(inherited)",
27692771
"@executable_path/Frameworks",

xcode/LDK/LDKFramework.xcodeproj/project.pbxproj

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1744,7 +1744,7 @@
17441744
);
17451745
runOnlyForDeploymentPostprocessing = 0;
17461746
shellPath = /bin/sh;
1747-
shellScript = "LDK_DIRECTORY=${PROJECT_DIR}/../../bindings/artifacts/ldk-c-bindings # directory to compile the C bindings in\nC_BINDINGS_SOURCE_DIRECTORY=\"$(cd ${LDK_DIRECTORY}; pwd)/lightning-c-bindings\"\n\nmkdir -p $PROJECT_DIR/headers\ncp \"${C_BINDINGS_SOURCE_DIRECTORY}/include/\"*.h $PROJECT_DIR/headers\ncp \"${LDK_DIRECTORY}/ldk-net/ldk_net.\"{c,h} $PROJECT_DIR/headers\n\nls -ll $PROJECT_DIR\n";
1747+
shellScript = "C_BINDINGS_SOURCE_DIRECTORY=\"$(cd ${LDK_DIRECTORY}; pwd)/lightning-c-bindings\"\n\nmkdir -p $PROJECT_DIR/headers\ncp \"${C_BINDINGS_SOURCE_DIRECTORY}/include/\"*.h $PROJECT_DIR/headers\ncp \"${LDK_DIRECTORY}/ldk-net/ldk_net.\"{c,h} $PROJECT_DIR/headers\n\nls -ll $PROJECT_DIR\n";
17481748
};
17491749
75A1A50028344C1800543ACC /* Copy Files From C Bindings Folder */ = {
17501750
isa = PBXShellScriptBuildPhase;
@@ -1767,7 +1767,7 @@
17671767
);
17681768
runOnlyForDeploymentPostprocessing = 0;
17691769
shellPath = /bin/sh;
1770-
shellScript = "LDK_DIRECTORY=${PROJECT_DIR}/../../bindings/artifacts/ldk-c-bindings # directory to compile the C bindings in\nC_BINDINGS_SOURCE_DIRECTORY=\"$(cd ${LDK_DIRECTORY}; pwd)/lightning-c-bindings\"\n\nmkdir -p $PROJECT_DIR/headers\ncp \"${C_BINDINGS_SOURCE_DIRECTORY}/include/\"*.h $PROJECT_DIR/headers\ncp \"${LDK_DIRECTORY}/ldk-net/ldk_net.\"{c,h} $PROJECT_DIR/headers\n\nls -ll $PROJECT_DIR\n";
1770+
shellScript = "C_BINDINGS_SOURCE_DIRECTORY=\"$(cd ${LDK_DIRECTORY}; pwd)/lightning-c-bindings\"\n\nmkdir -p $PROJECT_DIR/headers\ncp \"${C_BINDINGS_SOURCE_DIRECTORY}/include/\"*.h $PROJECT_DIR/headers\ncp \"${LDK_DIRECTORY}/ldk-net/ldk_net.\"{c,h} $PROJECT_DIR/headers\n\nls -ll $PROJECT_DIR\n";
17711771
};
17721772
/* End PBXShellScriptBuildPhase section */
17731773

@@ -2500,6 +2500,7 @@
25002500
GENERATE_INFOPLIST_FILE = YES;
25012501
INFOPLIST_KEY_NSHumanReadableCopyright = "";
25022502
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
2503+
LDK_DIRECTORY = "${PROJECT_DIR}/../../bindings/artifacts/ldk-c-bindings";
25032504
LD_RUNPATH_SEARCH_PATHS = (
25042505
"$(inherited)",
25052506
"@executable_path/../Frameworks",
@@ -2535,6 +2536,7 @@
25352536
GENERATE_INFOPLIST_FILE = YES;
25362537
INFOPLIST_KEY_NSHumanReadableCopyright = "";
25372538
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
2539+
LDK_DIRECTORY = "${PROJECT_DIR}/../../bindings/artifacts/ldk-c-bindings";
25382540
LD_RUNPATH_SEARCH_PATHS = (
25392541
"$(inherited)",
25402542
"@executable_path/../Frameworks",
@@ -2559,6 +2561,7 @@
25592561
754BD6582831607A0050F361 /* Debug */ = {
25602562
isa = XCBuildConfiguration;
25612563
buildSettings = {
2564+
LDK_DIRECTORY = "${PROJECT_DIR}/../bindings/artifacts/ldk-c-bindings";
25622565
PATH = "";
25632566
PRODUCT_NAME = "$(TARGET_NAME)";
25642567
SDKROOT = macosx;
@@ -2568,6 +2571,7 @@
25682571
754BD6592831607A0050F361 /* Release */ = {
25692572
isa = XCBuildConfiguration;
25702573
buildSettings = {
2574+
LDK_DIRECTORY = "${PROJECT_DIR}/../bindings/artifacts/ldk-c-bindings";
25712575
PATH = "";
25722576
PRODUCT_NAME = "$(TARGET_NAME)";
25732577
SDKROOT = macosx;
@@ -2708,6 +2712,8 @@
27082712
HEADER_SEARCH_PATHS = "${PROJECT_DIR}";
27092713
INFOPLIST_KEY_NSHumanReadableCopyright = "";
27102714
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
2715+
"IPHONEOS_DEPLOYMENT_TARGET[sdk=macosx*]" = 14.2;
2716+
LDK_DIRECTORY = "${PROJECT_DIR}/../../bindings/artifacts/ldk-c-bindings";
27112717
LD_RUNPATH_SEARCH_PATHS = (
27122718
"$(inherited)",
27132719
"@executable_path/Frameworks",
@@ -2743,6 +2749,8 @@
27432749
HEADER_SEARCH_PATHS = "${PROJECT_DIR}";
27442750
INFOPLIST_KEY_NSHumanReadableCopyright = "";
27452751
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
2752+
"IPHONEOS_DEPLOYMENT_TARGET[sdk=macosx*]" = 14.2;
2753+
LDK_DIRECTORY = "${PROJECT_DIR}/../../bindings/artifacts/ldk-c-bindings";
27462754
LD_RUNPATH_SEARCH_PATHS = (
27472755
"$(inherited)",
27482756
"@executable_path/Frameworks",
@@ -2767,6 +2775,7 @@
27672775
75D7577328306AD40005405B /* Debug */ = {
27682776
isa = XCBuildConfiguration;
27692777
buildSettings = {
2778+
LDK_DIRECTORY = "${PROJECT_DIR}/../bindings/artifacts/ldk-c-bindings";
27702779
PATH = "";
27712780
PRODUCT_NAME = "$(TARGET_NAME)";
27722781
};
@@ -2775,6 +2784,7 @@
27752784
75D7577428306AD40005405B /* Release */ = {
27762785
isa = XCBuildConfiguration;
27772786
buildSettings = {
2787+
LDK_DIRECTORY = "${PROJECT_DIR}/../bindings/artifacts/ldk-c-bindings";
27782788
PATH = "";
27792789
PRODUCT_NAME = "$(TARGET_NAME)";
27802790
};

xcode/LDK/build-libldk.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ fi
1212

1313
set -e # stop execution upon the first error
1414

15-
LDK_DIRECTORY=../bindings/artifacts/ldk-c-bindings # directory to compile the C bindings in
1615
C_BINDINGS_SOURCE_DIRECTORY="$(cd ${LDK_DIRECTORY}; pwd)/lightning-c-bindings"
1716

1817
if [[ ${ACTION:-build} = "build" || $ACTION = "install" ]]; then

0 commit comments

Comments
 (0)