diff --git a/.gitignore b/.gitignore
index 85015764..c6a078cc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,6 +31,8 @@ bdkFFI.h
BitcoinDevKit.swift
bdk.swift
.build
+bdkffi.xcframework
+*.modulemap
# Python related
__pycache__
\ No newline at end of file
diff --git a/bdk-swift/Package.swift b/bdk-swift/Package.swift
index 79d1817b..004aaa29 100644
--- a/bdk-swift/Package.swift
+++ b/bdk-swift/Package.swift
@@ -29,11 +29,14 @@ let package = Package(
.binaryTarget(name: "bdkFFI", path: "./bdkFFI.xcframework"),
.target(
name: "BitcoinDevKit",
- dependencies: ["bdkFFI"],
- swiftSettings: [.unsafeFlags(["-suppress-warnings"])]
+ dependencies: ["bdkFFI"]
),
.testTarget(
name: "BitcoinDevKitTests",
- dependencies: ["BitcoinDevKit"]),
+ dependencies: ["BitcoinDevKit"],
+ resources: [
+ .copy("Resources/pre_existing_wallet_persistence_test.sqlite")
+ ]
+ ),
]
)
diff --git a/bdk-swift/README.md b/bdk-swift/README.md
index 5de436af..9690b1a3 100644
--- a/bdk-swift/README.md
+++ b/bdk-swift/README.md
@@ -25,7 +25,7 @@ import BitcoinDevKit
Swift Package Manager releases for `bdk-swift` are published to a separate repository (https://github.com/bitcoindevkit/bdk-swift), and that is where the releases are created for it.
-The `bdk-swift/build-local-swift.sh` script can be used instead to create a version of the project for local testing.
+The `bdk-swift/build-xcframework.sh` script can be used instead to create a version of the project for local testing.
### How to test
@@ -35,7 +35,7 @@ swift test
### Example Projects
-* [BdkSwiftSample](https://github.com/futurepaul/BdkSwiftSample), iOS
+* [BDKSwiftExampleWallet](https://github.com/bitcoindevkit/BDKSwiftExampleWallet), iOS
## How to Build and Publish
diff --git a/bdk-swift/bdkFFI.xcframework/Info.plist b/bdk-swift/bdkFFI.xcframework/Info.plist
deleted file mode 100644
index bc36d1d2..00000000
--- a/bdk-swift/bdkFFI.xcframework/Info.plist
+++ /dev/null
@@ -1,59 +0,0 @@
-
-
-
-
- AvailableLibraries
-
-
- LibraryIdentifier
- macos-arm64_x86_64
- LibraryPath
- bdkFFI.framework
- SupportedArchitectures
-
- arm64
- x86_64
-
- SupportedPlatform
- macos
- LSMinimumSystemVersion
- 12.0
-
-
- LibraryIdentifier
- ios-arm64_x86_64-simulator
- LibraryPath
- bdkFFI.framework
- SupportedArchitectures
-
- arm64
- x86_64
-
- SupportedPlatform
- ios
- SupportedPlatformVariant
- simulator
- MinimumOSVersion
- 15.0
-
-
- LibraryIdentifier
- ios-arm64
- LibraryPath
- bdkFFI.framework
- SupportedArchitectures
-
- arm64
-
- SupportedPlatform
- ios
- MinimumOSVersion
- 15.0
-
-
- CFBundlePackageType
- XFWK
- XCFrameworkFormatVersion
- 1.0
-
-
diff --git a/bdk-swift/bdkFFI.xcframework/ios-arm64/bdkFFI.framework/Headers/bdkFFI-umbrella.h b/bdk-swift/bdkFFI.xcframework/ios-arm64/bdkFFI.framework/Headers/bdkFFI-umbrella.h
deleted file mode 100644
index c10f2d91..00000000
--- a/bdk-swift/bdkFFI.xcframework/ios-arm64/bdkFFI.framework/Headers/bdkFFI-umbrella.h
+++ /dev/null
@@ -1,4 +0,0 @@
-// This is the "umbrella header" for our combined Rust code library.
-// It needs to import all of the individual headers.
-
-#import "bdkFFI.h"
diff --git a/bdk-swift/bdkFFI.xcframework/ios-arm64/bdkFFI.framework/Info.plist b/bdk-swift/bdkFFI.xcframework/ios-arm64/bdkFFI.framework/Info.plist
deleted file mode 100644
index c448e2c0..00000000
--- a/bdk-swift/bdkFFI.xcframework/ios-arm64/bdkFFI.framework/Info.plist
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
- CFBundleIdentifier
- com.bitcoindevkit.bdkFFI
- CFBundleName
- bdkFFI
- CFBundleVersion
- 0.32.0
- CFBundleShortVersionString
- 0.32.0
- CFBundleExecutable
- bdkFFI
- MinimumOSVersion
- 100
-
-
\ No newline at end of file
diff --git a/bdk-swift/bdkFFI.xcframework/ios-arm64/bdkFFI.framework/Modules/module.modulemap b/bdk-swift/bdkFFI.xcframework/ios-arm64/bdkFFI.framework/Modules/module.modulemap
deleted file mode 100644
index 1b7f601d..00000000
--- a/bdk-swift/bdkFFI.xcframework/ios-arm64/bdkFFI.framework/Modules/module.modulemap
+++ /dev/null
@@ -1,6 +0,0 @@
-framework module bdkFFI {
- umbrella header "bdkFFI-umbrella.h"
-
- export *
- module * { export * }
-}
diff --git a/bdk-swift/bdkFFI.xcframework/ios-arm64_x86_64-simulator/bdkFFI.framework/Headers/bdkFFI-umbrella.h b/bdk-swift/bdkFFI.xcframework/ios-arm64_x86_64-simulator/bdkFFI.framework/Headers/bdkFFI-umbrella.h
deleted file mode 100644
index c10f2d91..00000000
--- a/bdk-swift/bdkFFI.xcframework/ios-arm64_x86_64-simulator/bdkFFI.framework/Headers/bdkFFI-umbrella.h
+++ /dev/null
@@ -1,4 +0,0 @@
-// This is the "umbrella header" for our combined Rust code library.
-// It needs to import all of the individual headers.
-
-#import "bdkFFI.h"
diff --git a/bdk-swift/bdkFFI.xcframework/ios-arm64_x86_64-simulator/bdkFFI.framework/Info.plist b/bdk-swift/bdkFFI.xcframework/ios-arm64_x86_64-simulator/bdkFFI.framework/Info.plist
deleted file mode 100644
index 55b1463c..00000000
--- a/bdk-swift/bdkFFI.xcframework/ios-arm64_x86_64-simulator/bdkFFI.framework/Info.plist
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
- CFBundleIdentifier
- com.bitcoindevkit.bdkFFI
- CFBundleName
- bdkFFI
- CFBundleVersion
- 0.32.0
- CFBundleShortVersionString
- 0.32.0
- CFBundleExecutable
- bdkFFI
- MinimumOSVersion
- 15.0
-
-
\ No newline at end of file
diff --git a/bdk-swift/bdkFFI.xcframework/ios-arm64_x86_64-simulator/bdkFFI.framework/Modules/module.modulemap b/bdk-swift/bdkFFI.xcframework/ios-arm64_x86_64-simulator/bdkFFI.framework/Modules/module.modulemap
deleted file mode 100644
index 1b7f601d..00000000
--- a/bdk-swift/bdkFFI.xcframework/ios-arm64_x86_64-simulator/bdkFFI.framework/Modules/module.modulemap
+++ /dev/null
@@ -1,6 +0,0 @@
-framework module bdkFFI {
- umbrella header "bdkFFI-umbrella.h"
-
- export *
- module * { export * }
-}
diff --git a/bdk-swift/bdkFFI.xcframework/macos-arm64_x86_64/bdkFFI.framework/Headers/bdkFFI-umbrella.h b/bdk-swift/bdkFFI.xcframework/macos-arm64_x86_64/bdkFFI.framework/Headers/bdkFFI-umbrella.h
deleted file mode 100644
index c10f2d91..00000000
--- a/bdk-swift/bdkFFI.xcframework/macos-arm64_x86_64/bdkFFI.framework/Headers/bdkFFI-umbrella.h
+++ /dev/null
@@ -1,4 +0,0 @@
-// This is the "umbrella header" for our combined Rust code library.
-// It needs to import all of the individual headers.
-
-#import "bdkFFI.h"
diff --git a/bdk-swift/bdkFFI.xcframework/macos-arm64_x86_64/bdkFFI.framework/Info.plist b/bdk-swift/bdkFFI.xcframework/macos-arm64_x86_64/bdkFFI.framework/Info.plist
deleted file mode 100644
index 85ead0f6..00000000
--- a/bdk-swift/bdkFFI.xcframework/macos-arm64_x86_64/bdkFFI.framework/Info.plist
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
- CFBundleIdentifier
- com.bitcoindevkit.bdkFFI
- CFBundleName
- bdkFFI
- CFBundleVersion
- 0.32.0
- CFBundleShortVersionString
- 0.32.0
- CFBundleExecutable
- bdkFFI
- LSMinimumSystemVersion
- 12.0
-
-
\ No newline at end of file
diff --git a/bdk-swift/bdkFFI.xcframework/macos-arm64_x86_64/bdkFFI.framework/Modules/module.modulemap b/bdk-swift/bdkFFI.xcframework/macos-arm64_x86_64/bdkFFI.framework/Modules/module.modulemap
deleted file mode 100644
index 1b7f601d..00000000
--- a/bdk-swift/bdkFFI.xcframework/macos-arm64_x86_64/bdkFFI.framework/Modules/module.modulemap
+++ /dev/null
@@ -1,6 +0,0 @@
-framework module bdkFFI {
- umbrella header "bdkFFI-umbrella.h"
-
- export *
- module * { export * }
-}
diff --git a/bdk-swift/build-local-swift.sh b/bdk-swift/build-local-swift.sh
deleted file mode 100755
index ba2806e2..00000000
--- a/bdk-swift/build-local-swift.sh
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/bin/bash
-# This script builds local swift-bdk Swift language bindings and corresponding bdkFFI.xcframework.
-# The results of this script can be used for locally testing your SPM package adding a local package
-# to your application pointing at the bdk-swift directory.
-#
-# Run the script from the repo root directory, ie: ./bdk-swift/build-local-swift.sh
-
-rustup install nightly-2023-04-10
-rustup component add rust-src --toolchain nightly-2023-04-10
-rustup target add aarch64-apple-ios x86_64-apple-ios
-rustup target add aarch64-apple-ios-sim --toolchain nightly-2023-04-10
-rustup target add aarch64-apple-darwin x86_64-apple-darwin
-
-pushd bdk-ffi
-mkdir -p Sources/BitcoinDevKit
-cargo run --bin uniffi-bindgen generate src/bdk.udl --language swift --out-dir ../bdk-swift/Sources/BitcoinDevKit --no-format
-popd
-
-cargo build --package bdk-ffi --profile release-smaller --target x86_64-apple-darwin
-cargo build --package bdk-ffi --profile release-smaller --target aarch64-apple-darwin
-cargo build --package bdk-ffi --profile release-smaller --target x86_64-apple-ios
-cargo build --package bdk-ffi --profile release-smaller --target aarch64-apple-ios
-cargo +nightly-2023-04-10 build --package bdk-ffi --profile release-smaller --target aarch64-apple-ios-sim
-
-mkdir -p target/lipo-ios-sim/release-smaller
-lipo target/aarch64-apple-ios-sim/release-smaller/libbdkffi.a target/x86_64-apple-ios/release-smaller/libbdkffi.a -create -output target/lipo-ios-sim/release-smaller/libbdkffi.a
-mkdir -p target/lipo-macos/release-smaller
-lipo target/aarch64-apple-darwin/release-smaller/libbdkffi.a target/x86_64-apple-darwin/release-smaller/libbdkffi.a -create -output target/lipo-macos/release-smaller/libbdkffi.a
-
-pushd bdk-swift
-mv Sources/BitcoinDevKit/bdk.swift Sources/BitcoinDevKit/BitcoinDevKit.swift
-cp Sources/BitcoinDevKit/bdkFFI.h bdkFFI.xcframework/ios-arm64/bdkFFI.framework/Headers
-cp Sources/BitcoinDevKit/bdkFFI.h bdkFFI.xcframework/ios-arm64_x86_64-simulator/bdkFFI.framework/Headers
-cp Sources/BitcoinDevKit/bdkFFI.h bdkFFI.xcframework/macos-arm64_x86_64/bdkFFI.framework/Headers
-cp ../target/aarch64-apple-ios/release-smaller/libbdkffi.a bdkFFI.xcframework/ios-arm64/bdkFFI.framework/bdkFFI
-cp ../target/lipo-ios-sim/release-smaller/libbdkffi.a bdkFFI.xcframework/ios-arm64_x86_64-simulator/bdkFFI.framework/bdkFFI
-cp ../target/lipo-macos/release-smaller/libbdkffi.a bdkFFI.xcframework/macos-arm64_x86_64/bdkFFI.framework/bdkFFI
-rm Sources/BitcoinDevKit/bdkFFI.h
-rm Sources/BitcoinDevKit/bdkFFI.modulemap
-#rm bdkFFI.xcframework.zip || true
-#zip -9 -r bdkFFI.xcframework.zip bdkFFI.xcframework
\ No newline at end of file
diff --git a/bdk-swift/build-xcframework.sh b/bdk-swift/build-xcframework.sh
new file mode 100755
index 00000000..60c99b67
--- /dev/null
+++ b/bdk-swift/build-xcframework.sh
@@ -0,0 +1,61 @@
+#!/bin/bash
+# This script builds local swift-bdk Swift language bindings and corresponding bdkFFI.xcframework.
+# The results of this script can be used for locally testing your SPM package adding a local package
+# to your application pointing at the bdk-swift directory.
+
+HEADERPATH="Sources/BitcoinDevKit/bdkFFI.h"
+MODMAPPATH="Sources/BitcoinDevKit/bdkFFI.modulemap"
+TARGETDIR="../target"
+OUTDIR="."
+RELDIR="release-smaller"
+NAME="bdkffi"
+STATIC_LIB_NAME="lib${NAME}.a"
+NEW_HEADER_DIR="../target/include"
+
+# set required rust version and install component and targets
+rustup default 1.77.1
+rustup component add rust-src
+rustup target add aarch64-apple-ios # iOS arm64
+rustup target add x86_64-apple-ios # iOS x86_64
+rustup target add aarch64-apple-ios-sim # simulator mac M1
+rustup target add aarch64-apple-darwin # mac M1
+rustup target add x86_64-apple-darwin # mac x86_64
+
+cd ../bdk-ffi/ || exit
+
+# build bdk-ffi rust lib for apple targets
+cargo build --package bdk-ffi --profile release-smaller --target x86_64-apple-darwin
+cargo build --package bdk-ffi --profile release-smaller --target aarch64-apple-darwin
+cargo build --package bdk-ffi --profile release-smaller --target x86_64-apple-ios
+cargo build --package bdk-ffi --profile release-smaller --target aarch64-apple-ios
+cargo build --package bdk-ffi --profile release-smaller --target aarch64-apple-ios-sim
+
+# build bdk-ffi Swift bindings and put in bdk-swift Sources
+cargo run --bin uniffi-bindgen generate --library ../target/aarch64-apple-ios/release-smaller/libbdkffi.dylib --language swift --out-dir ../bdk-swift/Sources/BitcoinDevKit --no-format
+
+# combine bdk-ffi static libs for aarch64 and x86_64 targets via lipo tool
+mkdir -p ../target/lipo-ios-sim/release-smaller
+lipo ../target/aarch64-apple-ios-sim/release-smaller/libbdkffi.a ../target/x86_64-apple-ios/release-smaller/libbdkffi.a -create -output ../target/lipo-ios-sim/release-smaller/libbdkffi.a
+mkdir -p ../target/lipo-macos/release-smaller
+lipo ../target/aarch64-apple-darwin/release-smaller/libbdkffi.a ../target/x86_64-apple-darwin/release-smaller/libbdkffi.a -create -output ../target/lipo-macos/release-smaller/libbdkffi.a
+
+cd ../bdk-swift/ || exit
+
+# move bdk-ffi static lib header files to temporary directory
+mkdir -p "${NEW_HEADER_DIR}"
+mv "${HEADERPATH}" "${NEW_HEADER_DIR}"
+mv "${MODMAPPATH}" "${NEW_HEADER_DIR}/module.modulemap"
+echo -e "\n" >> "${NEW_HEADER_DIR}/module.modulemap"
+
+# remove old xcframework directory
+rm -rf "${OUTDIR}/${NAME}.xcframework"
+
+# create new xcframework directory from bdk-ffi static libs and headers
+xcodebuild -create-xcframework \
+ -library "${TARGETDIR}/lipo-macos/${RELDIR}/${STATIC_LIB_NAME}" \
+ -headers "${NEW_HEADER_DIR}" \
+ -library "${TARGETDIR}/aarch64-apple-ios/${RELDIR}/${STATIC_LIB_NAME}" \
+ -headers "${NEW_HEADER_DIR}" \
+ -library "${TARGETDIR}/lipo-ios-sim/${RELDIR}/${STATIC_LIB_NAME}" \
+ -headers "${NEW_HEADER_DIR}" \
+ -output "${OUTDIR}/${NAME}.xcframework"
diff --git a/bdk-swift/justfile b/bdk-swift/justfile
new file mode 100644
index 00000000..4f837900
--- /dev/null
+++ b/bdk-swift/justfile
@@ -0,0 +1,14 @@
+default:
+ just --list
+
+build:
+ bash ./build-xcframework.sh
+
+clean:
+ rm -rf ../target bdkffi.xcframework Sources/BitcoinDevKit/*
+
+test:
+ swift test
+
+test-offline:
+ swift test --skip LiveElectrumClientTests --skip LiveMemoryWalletTests --skip LiveTransactionTests --skip LiveTxBuilderTests --skip LiveWalletTests