Skip to content

Commit

Permalink
Rename Swift modules to LDKNode/LDKNodeFFI
Browse files Browse the repository at this point in the history
  • Loading branch information
tnull committed Jun 19, 2023
1 parent 93d2619 commit 62df39c
Show file tree
Hide file tree
Showing 13 changed files with 45 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<key>LibraryIdentifier</key>
<string>macos-arm64_x86_64</string>
<key>LibraryPath</key>
<string>ldk_nodeFFI.framework</string>
<string>LDKNodeFFI.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
Expand All @@ -21,7 +21,7 @@
<key>LibraryIdentifier</key>
<string>ios-arm64_x86_64-simulator</string>
<key>LibraryPath</key>
<string>ldk_nodeFFI.framework</string>
<string>LDKNodeFFI.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
Expand All @@ -36,7 +36,7 @@
<key>LibraryIdentifier</key>
<string>ios-arm64</string>
<key>LibraryPath</key>
<string>ldk_nodeFFI.framework</string>
<string>LDKNodeFFI.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This is the "umbrella header" for our combined Rust code library.
// It needs to import all of the individual headers.

#import "ldk_nodeFFI.h"
#import "LDKNodeFFI.h"
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
framework module LDKNodeFFI {
umbrella header "LDKNodeFFI-umbrella.h"

export *
module * { export * }
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This is the "umbrella header" for our combined Rust code library.
// It needs to import all of the individual headers.

#import "ldk_nodeFFI.h"
#import "LDKNodeFFI.h"
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
framework module LDKNodeFFI {
umbrella header "LDKNodeFFI-umbrella.h"

export *
module * { export * }
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This is the "umbrella header" for our combined Rust code library.
// It needs to import all of the individual headers.

#import "ldk_nodeFFI.h"
#import "LDKNodeFFI.h"
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
framework module LDKNodeFFI {
umbrella header "LDKNodeFFI-umbrella.h"

export *
module * { export * }
}
14 changes: 7 additions & 7 deletions bindings/swift/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ let package = Package(
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "LightningDevKitNode",
targets: ["ldk_nodeFFI", "LightningDevKitNode"]),
name: "LDKNode",
targets: ["LDKNodeFFI", "LDKNode"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
Expand All @@ -23,13 +23,13 @@ let package = Package(
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
// .binaryTarget(
// name: "ldk_nodeFFI",
// url: "https://github.com/lightningdevkit/ldk-node/releases/download/0.3.0/ldk_nodeFFI.xcframework.zip",
// name: "LDKNodeFFI",
// url: "https://github.com/lightningdevkit/ldk-node/releases/download/0.3.0/LDKNodeFFI.xcframework.zip",
// checksum: "<TBD>"),
.binaryTarget(name: "ldk_nodeFFI", path: "./ldk_nodeFFI.xcframework"),
.binaryTarget(name: "LDKNodeFFI", path: "./LDKNodeFFI.xcframework"),
.target(
name: "LightningDevKitNode",
dependencies: ["ldk_nodeFFI"]),
name: "LDKNode",
dependencies: ["LDKNodeFFI"]),
// .testTarget(
// name: "LightningDevKitNodeTests",
// dependencies: ["LightningDevKitNode"]),
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

22 changes: 11 additions & 11 deletions scripts/uniffi_bindgen_generate_swift.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ lipo target/aarch64-apple-darwin/release-smaller/libldk_node.a target/x86_64-app

$UNIFFI_BINDGEN_BIN generate bindings/ldk_node.udl --language swift -o "$BINDINGS_DIR" || exit 1

swiftc -module-name ldk_node -emit-library -o "$BINDINGS_DIR"/libldk_node.dylib -emit-module -emit-module-path "$BINDINGS_DIR" -parse-as-library -L ./target/release-smaller -lldk_node -Xcc -fmodule-map-file="$BINDINGS_DIR"/ldk_nodeFFI.modulemap "$BINDINGS_DIR"/ldk_node.swift -v || exit 1
swiftc -module-name LDKNode -emit-library -o "$BINDINGS_DIR"/libldk_node.dylib -emit-module -emit-module-path "$BINDINGS_DIR" -parse-as-library -L ./target/release-smaller -lldk_node -Xcc -fmodule-map-file="$BINDINGS_DIR"/LDKNodeFFI.modulemap "$BINDINGS_DIR"/LDKNode.swift -v || exit 1

# Create xcframework from bindings Swift file and libs
mkdir -p "$BINDINGS_DIR"/Sources/LightningDevKitNode || exit 1
mv "$BINDINGS_DIR"/ldk_node.swift "$BINDINGS_DIR"/Sources/LightningDevKitNode/LightningDevKitNode.swift || exit 1
cp "$BINDINGS_DIR"/ldk_nodeFFI.h "$BINDINGS_DIR"/ldk_nodeFFI.xcframework/ios-arm64/ldk_nodeFFI.framework/Headers || exit 1
cp "$BINDINGS_DIR"/ldk_nodeFFI.h "$BINDINGS_DIR"/ldk_nodeFFI.xcframework/ios-arm64_x86_64-simulator/ldk_nodeFFI.framework/Headers || exit 1
cp "$BINDINGS_DIR"/ldk_nodeFFI.h "$BINDINGS_DIR"/ldk_nodeFFI.xcframework/macos-arm64_x86_64/ldk_nodeFFI.framework/Headers || exit 1
cp target/aarch64-apple-ios/release-smaller/libldk_node.a "$BINDINGS_DIR"/ldk_nodeFFI.xcframework/ios-arm64/ldk_nodeFFI.framework/ldk_nodeFFI || exit 1
cp target/lipo-ios-sim/release-smaller/libldk_node.a "$BINDINGS_DIR"/ldk_nodeFFI.xcframework/ios-arm64_x86_64-simulator/ldk_nodeFFI.framework/ldk_nodeFFI || exit 1
cp target/lipo-macos/release-smaller/libldk_node.a "$BINDINGS_DIR"/ldk_nodeFFI.xcframework/macos-arm64_x86_64/ldk_nodeFFI.framework/ldk_nodeFFI || exit 1
# rm "$BINDINGS_DIR"/ldk_nodeFFI.h || exit 1
# rm "$BINDINGS_DIR"/ldk_nodeFFI.modulemap || exit 1
mkdir -p "$BINDINGS_DIR"/Sources/LDKNode || exit 1
mv "$BINDINGS_DIR"/LDKNode.swift "$BINDINGS_DIR"/Sources/LDKNode/LDKNode.swift || exit 1
cp "$BINDINGS_DIR"/LDKNodeFFI.h "$BINDINGS_DIR"/LDKNodeFFI.xcframework/ios-arm64/LDKNodeFFI.framework/Headers || exit 1
cp "$BINDINGS_DIR"/LDKNodeFFI.h "$BINDINGS_DIR"/LDKNodeFFI.xcframework/ios-arm64_x86_64-simulator/LDKNodeFFI.framework/Headers || exit 1
cp "$BINDINGS_DIR"/LDKNodeFFI.h "$BINDINGS_DIR"/LDKNodeFFI.xcframework/macos-arm64_x86_64/LDKNodeFFI.framework/Headers || exit 1
cp target/aarch64-apple-ios/release-smaller/libldk_node.a "$BINDINGS_DIR"/LDKNodeFFI.xcframework/ios-arm64/LDKNodeFFI.framework/LDKNodeFFI || exit 1
cp target/lipo-ios-sim/release-smaller/libldk_node.a "$BINDINGS_DIR"/LDKNodeFFI.xcframework/ios-arm64_x86_64-simulator/LDKNodeFFI.framework/LDKNodeFFI || exit 1
cp target/lipo-macos/release-smaller/libldk_node.a "$BINDINGS_DIR"/LDKNodeFFI.xcframework/macos-arm64_x86_64/LDKNodeFFI.framework/LDKNodeFFI || exit 1
# rm "$BINDINGS_DIR"/LDKNodeFFI.h || exit 1
# rm "$BINDINGS_DIR"/LDKNodeFFI.modulemap || exit 1
echo finished successfully!
3 changes: 3 additions & 0 deletions uniffi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ cdylib_name = "ldk_node"
cdylib_name = "ldk_node"

[bindings.swift]
module_name = "LDKNode"
ffi_module_name = "LDKNodeFFI"
ffi_module_filename ="LDKNodeFFI"
cdylib_name = "ldk_node"

0 comments on commit 62df39c

Please sign in to comment.