From 62df39c1cdfbdf2d3083b50ce8d4b0c5d15effb9 Mon Sep 17 00:00:00 2001 From: Elias Rohrer Date: Mon, 19 Jun 2023 10:47:06 +0200 Subject: [PATCH] Rename Swift modules to `LDKNode`/`LDKNodeFFI` --- .../Info.plist | 6 ++--- .../Headers/LDKNodeFFI-umbrella.h} | 2 +- .../Modules/module.modulemap | 6 +++++ .../Headers/LDKNodeFFI-umbrella.h} | 2 +- .../Modules/module.modulemap | 6 +++++ .../Headers/LDKNodeFFI-umbrella.h} | 2 +- .../Modules/module.modulemap | 6 +++++ bindings/swift/Package.swift | 14 ++++++------ .../Modules/module.modulemap | 6 ----- .../Modules/module.modulemap | 6 ----- .../Modules/module.modulemap | 6 ----- scripts/uniffi_bindgen_generate_swift.sh | 22 +++++++++---------- uniffi.toml | 3 +++ 13 files changed, 45 insertions(+), 42 deletions(-) rename bindings/swift/{ldk_nodeFFI.xcframework => LDKNodeFFI.xcframework}/Info.plist (90%) rename bindings/swift/{ldk_nodeFFI.xcframework/ios-arm64/ldk_nodeFFI.framework/Headers/ldk_nodeFFI-umbrella.h => LDKNodeFFI.xcframework/ios-arm64/LDKNodeFFI.framework/Headers/LDKNodeFFI-umbrella.h} (83%) create mode 100644 bindings/swift/LDKNodeFFI.xcframework/ios-arm64/LDKNodeFFI.framework/Modules/module.modulemap rename bindings/swift/{ldk_nodeFFI.xcframework/macos-arm64_x86_64/ldk_nodeFFI.framework/Headers/ldk_nodeFFI-umbrella.h => LDKNodeFFI.xcframework/ios-arm64_x86_64-simulator/LDKNodeFFI.framework/Headers/LDKNodeFFI-umbrella.h} (83%) create mode 100644 bindings/swift/LDKNodeFFI.xcframework/ios-arm64_x86_64-simulator/LDKNodeFFI.framework/Modules/module.modulemap rename bindings/swift/{ldk_nodeFFI.xcframework/ios-arm64_x86_64-simulator/ldk_nodeFFI.framework/Headers/ldk_nodeFFI-umbrella.h => LDKNodeFFI.xcframework/macos-arm64_x86_64/LDKNodeFFI.framework/Headers/LDKNodeFFI-umbrella.h} (83%) create mode 100644 bindings/swift/LDKNodeFFI.xcframework/macos-arm64_x86_64/LDKNodeFFI.framework/Modules/module.modulemap delete mode 100644 bindings/swift/ldk_nodeFFI.xcframework/ios-arm64/ldk_nodeFFI.framework/Modules/module.modulemap delete mode 100644 bindings/swift/ldk_nodeFFI.xcframework/ios-arm64_x86_64-simulator/ldk_nodeFFI.framework/Modules/module.modulemap delete mode 100644 bindings/swift/ldk_nodeFFI.xcframework/macos-arm64_x86_64/ldk_nodeFFI.framework/Modules/module.modulemap diff --git a/bindings/swift/ldk_nodeFFI.xcframework/Info.plist b/bindings/swift/LDKNodeFFI.xcframework/Info.plist similarity index 90% rename from bindings/swift/ldk_nodeFFI.xcframework/Info.plist rename to bindings/swift/LDKNodeFFI.xcframework/Info.plist index d0d1ee6fc..ee11d9a89 100644 --- a/bindings/swift/ldk_nodeFFI.xcframework/Info.plist +++ b/bindings/swift/LDKNodeFFI.xcframework/Info.plist @@ -8,7 +8,7 @@ LibraryIdentifier macos-arm64_x86_64 LibraryPath - ldk_nodeFFI.framework + LDKNodeFFI.framework SupportedArchitectures arm64 @@ -21,7 +21,7 @@ LibraryIdentifier ios-arm64_x86_64-simulator LibraryPath - ldk_nodeFFI.framework + LDKNodeFFI.framework SupportedArchitectures arm64 @@ -36,7 +36,7 @@ LibraryIdentifier ios-arm64 LibraryPath - ldk_nodeFFI.framework + LDKNodeFFI.framework SupportedArchitectures arm64 diff --git a/bindings/swift/ldk_nodeFFI.xcframework/ios-arm64/ldk_nodeFFI.framework/Headers/ldk_nodeFFI-umbrella.h b/bindings/swift/LDKNodeFFI.xcframework/ios-arm64/LDKNodeFFI.framework/Headers/LDKNodeFFI-umbrella.h similarity index 83% rename from bindings/swift/ldk_nodeFFI.xcframework/ios-arm64/ldk_nodeFFI.framework/Headers/ldk_nodeFFI-umbrella.h rename to bindings/swift/LDKNodeFFI.xcframework/ios-arm64/LDKNodeFFI.framework/Headers/LDKNodeFFI-umbrella.h index ecc6775bc..51a02f031 100644 --- a/bindings/swift/ldk_nodeFFI.xcframework/ios-arm64/ldk_nodeFFI.framework/Headers/ldk_nodeFFI-umbrella.h +++ b/bindings/swift/LDKNodeFFI.xcframework/ios-arm64/LDKNodeFFI.framework/Headers/LDKNodeFFI-umbrella.h @@ -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" diff --git a/bindings/swift/LDKNodeFFI.xcframework/ios-arm64/LDKNodeFFI.framework/Modules/module.modulemap b/bindings/swift/LDKNodeFFI.xcframework/ios-arm64/LDKNodeFFI.framework/Modules/module.modulemap new file mode 100644 index 000000000..a18e710d3 --- /dev/null +++ b/bindings/swift/LDKNodeFFI.xcframework/ios-arm64/LDKNodeFFI.framework/Modules/module.modulemap @@ -0,0 +1,6 @@ +framework module LDKNodeFFI { + umbrella header "LDKNodeFFI-umbrella.h" + + export * + module * { export * } +} diff --git a/bindings/swift/ldk_nodeFFI.xcframework/macos-arm64_x86_64/ldk_nodeFFI.framework/Headers/ldk_nodeFFI-umbrella.h b/bindings/swift/LDKNodeFFI.xcframework/ios-arm64_x86_64-simulator/LDKNodeFFI.framework/Headers/LDKNodeFFI-umbrella.h similarity index 83% rename from bindings/swift/ldk_nodeFFI.xcframework/macos-arm64_x86_64/ldk_nodeFFI.framework/Headers/ldk_nodeFFI-umbrella.h rename to bindings/swift/LDKNodeFFI.xcframework/ios-arm64_x86_64-simulator/LDKNodeFFI.framework/Headers/LDKNodeFFI-umbrella.h index ecc6775bc..51a02f031 100644 --- a/bindings/swift/ldk_nodeFFI.xcframework/macos-arm64_x86_64/ldk_nodeFFI.framework/Headers/ldk_nodeFFI-umbrella.h +++ b/bindings/swift/LDKNodeFFI.xcframework/ios-arm64_x86_64-simulator/LDKNodeFFI.framework/Headers/LDKNodeFFI-umbrella.h @@ -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" diff --git a/bindings/swift/LDKNodeFFI.xcframework/ios-arm64_x86_64-simulator/LDKNodeFFI.framework/Modules/module.modulemap b/bindings/swift/LDKNodeFFI.xcframework/ios-arm64_x86_64-simulator/LDKNodeFFI.framework/Modules/module.modulemap new file mode 100644 index 000000000..a18e710d3 --- /dev/null +++ b/bindings/swift/LDKNodeFFI.xcframework/ios-arm64_x86_64-simulator/LDKNodeFFI.framework/Modules/module.modulemap @@ -0,0 +1,6 @@ +framework module LDKNodeFFI { + umbrella header "LDKNodeFFI-umbrella.h" + + export * + module * { export * } +} diff --git a/bindings/swift/ldk_nodeFFI.xcframework/ios-arm64_x86_64-simulator/ldk_nodeFFI.framework/Headers/ldk_nodeFFI-umbrella.h b/bindings/swift/LDKNodeFFI.xcframework/macos-arm64_x86_64/LDKNodeFFI.framework/Headers/LDKNodeFFI-umbrella.h similarity index 83% rename from bindings/swift/ldk_nodeFFI.xcframework/ios-arm64_x86_64-simulator/ldk_nodeFFI.framework/Headers/ldk_nodeFFI-umbrella.h rename to bindings/swift/LDKNodeFFI.xcframework/macos-arm64_x86_64/LDKNodeFFI.framework/Headers/LDKNodeFFI-umbrella.h index ecc6775bc..51a02f031 100644 --- a/bindings/swift/ldk_nodeFFI.xcframework/ios-arm64_x86_64-simulator/ldk_nodeFFI.framework/Headers/ldk_nodeFFI-umbrella.h +++ b/bindings/swift/LDKNodeFFI.xcframework/macos-arm64_x86_64/LDKNodeFFI.framework/Headers/LDKNodeFFI-umbrella.h @@ -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" diff --git a/bindings/swift/LDKNodeFFI.xcframework/macos-arm64_x86_64/LDKNodeFFI.framework/Modules/module.modulemap b/bindings/swift/LDKNodeFFI.xcframework/macos-arm64_x86_64/LDKNodeFFI.framework/Modules/module.modulemap new file mode 100644 index 000000000..a18e710d3 --- /dev/null +++ b/bindings/swift/LDKNodeFFI.xcframework/macos-arm64_x86_64/LDKNodeFFI.framework/Modules/module.modulemap @@ -0,0 +1,6 @@ +framework module LDKNodeFFI { + umbrella header "LDKNodeFFI-umbrella.h" + + export * + module * { export * } +} diff --git a/bindings/swift/Package.swift b/bindings/swift/Package.swift index 7ae8aee70..8f5e52a0f 100644 --- a/bindings/swift/Package.swift +++ b/bindings/swift/Package.swift @@ -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. @@ -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: ""), - .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"]), diff --git a/bindings/swift/ldk_nodeFFI.xcframework/ios-arm64/ldk_nodeFFI.framework/Modules/module.modulemap b/bindings/swift/ldk_nodeFFI.xcframework/ios-arm64/ldk_nodeFFI.framework/Modules/module.modulemap deleted file mode 100644 index 7a6998828..000000000 --- a/bindings/swift/ldk_nodeFFI.xcframework/ios-arm64/ldk_nodeFFI.framework/Modules/module.modulemap +++ /dev/null @@ -1,6 +0,0 @@ -framework module ldk_nodeFFI { - umbrella header "ldk_nodeFFI-umbrella.h" - - export * - module * { export * } -} diff --git a/bindings/swift/ldk_nodeFFI.xcframework/ios-arm64_x86_64-simulator/ldk_nodeFFI.framework/Modules/module.modulemap b/bindings/swift/ldk_nodeFFI.xcframework/ios-arm64_x86_64-simulator/ldk_nodeFFI.framework/Modules/module.modulemap deleted file mode 100644 index 7a6998828..000000000 --- a/bindings/swift/ldk_nodeFFI.xcframework/ios-arm64_x86_64-simulator/ldk_nodeFFI.framework/Modules/module.modulemap +++ /dev/null @@ -1,6 +0,0 @@ -framework module ldk_nodeFFI { - umbrella header "ldk_nodeFFI-umbrella.h" - - export * - module * { export * } -} diff --git a/bindings/swift/ldk_nodeFFI.xcframework/macos-arm64_x86_64/ldk_nodeFFI.framework/Modules/module.modulemap b/bindings/swift/ldk_nodeFFI.xcframework/macos-arm64_x86_64/ldk_nodeFFI.framework/Modules/module.modulemap deleted file mode 100644 index 7a6998828..000000000 --- a/bindings/swift/ldk_nodeFFI.xcframework/macos-arm64_x86_64/ldk_nodeFFI.framework/Modules/module.modulemap +++ /dev/null @@ -1,6 +0,0 @@ -framework module ldk_nodeFFI { - umbrella header "ldk_nodeFFI-umbrella.h" - - export * - module * { export * } -} diff --git a/scripts/uniffi_bindgen_generate_swift.sh b/scripts/uniffi_bindgen_generate_swift.sh index 042e157be..0ec165bde 100755 --- a/scripts/uniffi_bindgen_generate_swift.sh +++ b/scripts/uniffi_bindgen_generate_swift.sh @@ -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! diff --git a/uniffi.toml b/uniffi.toml index 57655582d..9e429034f 100644 --- a/uniffi.toml +++ b/uniffi.toml @@ -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"