Skip to content

Commit 6b43f5b

Browse files
committed
fix: update build scripts
1 parent 449bf00 commit 6b43f5b

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

scripts/uniffi_bindgen_generate.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
11
#!/bin/bash
2+
set -eox pipefail
3+
4+
# Set deployment targets
5+
export IPHONEOS_DEPLOYMENT_TARGET=13.0
6+
export MACOSX_DEPLOYMENT_TARGET=10.15
7+
8+
# Set CMake-specific deployment targets to match
9+
export CMAKE_OSX_DEPLOYMENT_TARGET=$IPHONEOS_DEPLOYMENT_TARGET
10+
export CMAKE_IOS_DEPLOYMENT_TARGET=$IPHONEOS_DEPLOYMENT_TARGET
11+
12+
# Clear any potentially conflicting environment variables
13+
unset SDKROOT
14+
unset BINDGEN_EXTRA_CLANG_ARGS
15+
216
source ./scripts/uniffi_bindgen_generate_kotlin.sh || exit 1
317
source ./scripts/uniffi_bindgen_generate_python.sh || exit 1
418
source ./scripts/uniffi_bindgen_generate_swift.sh || exit 1

scripts/uniffi_bindgen_generate_swift.sh

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,32 @@ rustup target add aarch64-apple-darwin x86_64-apple-darwin --toolchain stable
2020
cargo build --profile release-smaller --features uniffi || exit 1
2121
cargo build --profile release-smaller --features uniffi --target x86_64-apple-darwin || exit 1
2222
cargo build --profile release-smaller --features uniffi --target aarch64-apple-darwin || exit 1
23-
cargo build --profile release-smaller --features uniffi --target x86_64-apple-ios || exit 1
23+
24+
# Build iOS device targets
25+
export SDKROOT=$(xcrun --sdk iphoneos --show-sdk-path)
2426
cargo build --profile release-smaller --features uniffi --target aarch64-apple-ios || exit 1
25-
cargo +stable build --release --features uniffi --target aarch64-apple-ios-sim || exit 1
27+
28+
# Build iOS simulator targets
29+
export SDKROOT=$(xcrun --sdk iphonesimulator --show-sdk-path)
30+
cargo build --profile release-smaller --features uniffi --target x86_64-apple-ios || exit 1
31+
32+
# For aarch64 simulator, set the additional environment variable
33+
export SDKROOT=$(xcrun --sdk iphonesimulator --show-sdk-path)
34+
export BINDGEN_EXTRA_CLANG_ARGS="--target=arm64-apple-ios-simulator"
35+
cargo +stable build --profile release-smaller --features uniffi --target aarch64-apple-ios-sim || exit 1
2636

2737
# Combine ios-sim and apple-darwin (macos) libs for x86_64 and aarch64 (m1)
2838
mkdir -p target/lipo-ios-sim/release-smaller || exit 1
29-
lipo target/aarch64-apple-ios-sim/release/libldk_node.a target/x86_64-apple-ios/release-smaller/libldk_node.a -create -output target/lipo-ios-sim/release-smaller/libldk_node.a || exit 1
39+
lipo target/aarch64-apple-ios-sim/release-smaller/libldk_node.a target/x86_64-apple-ios/release-smaller/libldk_node.a -create -output target/lipo-ios-sim/release-smaller/libldk_node.a || exit 1
3040
mkdir -p target/lipo-macos/release-smaller || exit 1
3141
lipo target/aarch64-apple-darwin/release-smaller/libldk_node.a target/x86_64-apple-darwin/release-smaller/libldk_node.a -create -output target/lipo-macos/release-smaller/libldk_node.a || exit 1
3242

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

45+
# Reset SDKROOT for macOS compilation
46+
unset SDKROOT
47+
unset BINDGEN_EXTRA_CLANG_ARGS
48+
3549
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
3650

3751
# Create xcframework from bindings Swift file and libs

0 commit comments

Comments
 (0)