bitcoindevkit / bdk-ffi

Please consider this project *experimental*. But we hope to have an official release out soon.
Other
85 stars 37 forks source link

swift package doesn't support macOS, watchOS etc... #367

Open cedricloneux opened 1 year ago

cedricloneux commented 1 year ago

I am working on a cross-platform app that should work on all Apple's systems. iOS, macOS, watchOS When I tried to run the Mac app, I was blocked by this error message saying that the package is not compatible. image

Would it be possible to fix that issue and support all platforms?

notmandatory commented 1 year ago

Our bdk-swift swift package does include MacOS (M1 and x86), plus the iOS (including M1 and x86 simulator). For watchOS support, it looks like it has tier 3 support for rust (https://github.com/rust-lang/rust/blob/master/src/doc/rustc/src/platform-support/apple-watchos.md) so we might be able to support it.

notmandatory commented 1 year ago

I noticed also you're using Mac Catalyst, is any available swift package supposed to work with it? I haven't used it before. https://developer.apple.com/mac-catalyst/

notmandatory commented 1 year ago

It looks like there may be some additional xcframework packaging voodoo to get them to work with Catalyst:

https://developer.apple.com/documentation/xcode/creating-a-multi-platform-binary-framework-bundle#Create-archives-for-frameworks-or-libraries

notmandatory commented 1 year ago

I made a simple test MacOS app, added package bdk-swift 0.28, imported it and used a couple BDK functions and it worked fine for me. Note I did not try to use Catalyst.

reez commented 2 months ago

As notmandatory mentioned everything works for a macOS app, but Mac Catalyst has some interesting nuances to get it working for a framework like bdk-swift; but I think we can make this happen or at least I'd like to try it out with something like adding this in our workflows (bdk-ffi + bdk-swift):

name: "Install Rust targets"

rustup target add aarch64-apple-ios-macabi # Mac Catalyst ARM64
rustup target add x86_64-apple-ios-macabi # Mac Catalyst x86_64

name: "Build bdk-ffi for all targets"

cargo build --profile release-smaller --target aarch64-apple-ios-macabi
cargo build --profile release-smaller --target x86_64-apple-ios-macabi

name: "Create universal binary for Mac Catalyst"

mkdir -p target/universal/release-smaller
    lipo -create \
      target/aarch64-apple-ios-macabi/release/libbdkffi.a \
      target/x86_64-apple-ios-macabi/release/libbdkffi.a \
      -output target/universal/release-smaller/libbdkffi_catalyst.a

... and so on.

@cedricloneux do you still have a need for Mac Catalyst support?