@@ -6,47 +6,64 @@ pushd bdk-ffi
66echo " Confirm bdk-ffi rust lib builds"
77cargo build --release
88
9- # # build bdk-ffi rust libs for apple targets
10- echo " Build bdk-ffi libs for apple targets "
9+ echo " Generate bdk-ffi swift bindings "
10+ uniffi-bindgen generate src/ bdk.udl --no-format --out-dir ../Sources/BitcoinDevKit --language swift
1111
12- TARGET_TRIPLES=(" x86_64-apple-darwin" " x86_64-apple-ios" " aarch64-apple-ios" )
12+ # # build bdk-ffi rust libs for apple targets and add to xcframework
13+ echo " Build bdk-ffi libs for apple targets and add to xcframework"
14+
15+ TARGET_TRIPLES=(" x86_64-apple-darwin" " aarch64-apple-darwin" " x86_64-apple-ios" " aarch64-apple-ios" )
16+ # XCFRAMEWORK_LIBS=""
1317for TARGET in ${TARGET_TRIPLES[@]} ; do
1418 echo " Build bdk-ffi lib for target $TARGET "
1519 cargo build --release --target $TARGET
20+ # XCFRAMEWORK_LIBS="$XCFRAMEWORK_LIBS -library target/$TARGET/release/libbdkffi.a"
1621done
17-
18- echo " Generate bdk-ffi swift bindings"
19- uniffi-bindgen generate src/bdk.udl --no-format --out-dir ../Sources/BitcoinDevKit --language swift
22+ # special build for M1 ios simulator
23+ cargo +nightly build --release -Z build-std --target aarch64-apple-ios-sim
24+
25+ echo " Create lipo static libs for ios-sim to support M1"
26+ mkdir -p target/lipo-ios-sim/release
27+ lipo target/aarch64-apple-ios-sim/release/libbdkffi.a target/x86_64-apple-ios/release/libbdkffi.a -create -output target/lipo-ios-sim/release/libbdkffi.a
28+
29+ echo " Create lipo static libs for macos to support M1"
30+ mkdir -p target/lipo-macos/release
31+ lipo target/aarch64-apple-darwin/release/libbdkffi.a target/x86_64-apple-darwin/release/libbdkffi.a -create -output target/lipo-macos/release/libbdkffi.a
32+
33+ # echo "Create xcframework with xcodebuild"
34+ # xcodebuild -create-xcframework \
35+ # -library target/lipo-ios-sim/release/libbdkffi.a \
36+ # -library target/lipo-macos/release/libbdkffi.a \
37+ # -library target/aarch64-apple-ios/release/libbdkffi.a \
38+ # -output ../bdkFFI.xcframework
39+
2040popd
2141
2242# rename bdk.swift bindings to BitcoinDevKit.swift
2343mv Sources/BitcoinDevKit/bdk.swift Sources/BitcoinDevKit/BitcoinDevKit.swift
2444
25- # copy bdkFFI.h to bdkFFI.xcframework platforms
26- PLATFORMS=( " macos-x86_64 " " ios-arm64_x86_64-simulator " " ios-arm64 " )
27- for PLATFORM in ${PLATFORMS[@]} ; do
28- cp Sources/BitcoinDevKit/bdkFFI.h bdkFFI.xcframework/$PLATFORM /bdkFFI.framework/Headers
45+ XCFRAMEWORK_LIBS=( " ios-arm64 " " ios-arm64_x86_64-simulator " " macos-arm64_x86_64 " )
46+ for LIB in ${XCFRAMEWORK_LIBS[@]} ; do
47+ # copy possibly updated header file
48+ cp Sources/BitcoinDevKit/bdkFFI.h bdkFFI.xcframework/$LIB /bdkFFI.framework/Headers
2949done
3050
51+ echo " Copy libbdkffi.a files to bdkFFI.xcframework/bdkFFI"
52+ cp bdk-ffi/target/aarch64-apple-ios/release/libbdkffi.a bdkFFI.xcframework/ios-arm64/bdkFFI.framework/bdkFFI
53+ cp bdk-ffi/target/lipo-ios-sim/release/libbdkffi.a bdkFFI.xcframework/ios-arm64_x86_64-simulator/bdkFFI.framework/bdkFFI
54+ cp bdk-ffi/target/lipo-macos/release/libbdkffi.a bdkFFI.xcframework/macos-arm64_x86_64/bdkFFI.framework/bdkFFI
55+
3156# remove unneed .h and .modulemap files
3257rm Sources/BitcoinDevKit/bdkFFI.h
3358rm Sources/BitcoinDevkit/bdkFFI.modulemap
3459
35- # add bdkFFI libs to bdkFFI.xcframework
36-
37- # macos-x86_64 platform
38- cp bdk-ffi/target/x86_64-apple-darwin/release/libbdkffi.a bdkFFI.xcframework/macos-x86_64/bdkFFI.framework/bdkFFI
39-
40- # ios-arm64 platform
41- cp bdk-ffi/target/aarch64-apple-ios/release/libbdkffi.a bdkFFI.xcframework/ios-arm64/bdkFFI.framework/bdkFFI
42-
43- # ios-arm64_x86_64-simulator, currently x86_64 only (need to make fat binary to add M1)
44- cp bdk-ffi/target/x86_64-apple-ios/release/libbdkffi.a bdkFFI.xcframework/ios-arm64_x86_64-simulator/bdkFFI.framework/bdkFFI
45-
4660# TODO add license info
4761
48- # remove any existing bdkFFI.xcframework.zip
49- rm bdkFFI.xcframework.zip
62+ if test -f " bdkFFI.xcframework.zip" ; then
63+ echo " Remove old bdkFFI.xcframework.zip"
64+ rm bdkFFI.xcframework.zip
65+ fi
66+
5067
5168# zip bdkFFI.xcframework directory into a bundle for distribution
5269zip -9 -r bdkFFI.xcframework.zip bdkFFI.xcframework
0 commit comments