Sjors / libwally-swift

Swift wrapper for LibWally, a collection of useful primitives for cryptocurrency wallets
MIT License
40 stars 18 forks source link

[wip] Cleanup build script, use XCFramework #61

Closed jurvis closed 2 years ago

jurvis commented 2 years ago

This PR is still a work in progress! fixes https://github.com/Sjors/libwally-swift/issues/59

Purpose

This PR primarily does a few things:

  1. Support latest libtool@2.4.7 change which will require a PR merge in libwally-core (https://github.com/ElementsProject/libwally-core/pull/321)2.
  2. Support running in iOS simulator on M1 Macs

Implementation

To achieve 1, I noticed that the latest libwally-core change no longer includes libsecp256k1 symbols inside the libwally-core.a library. To keep this simple, I imported libsecp256k1.a from CLibWally/libwally-core/src/secp256k1/.libs to the Xcode project

To achieve 2, we will have to build an xcodebuild -xcframework instead of using the previous lipo build command. This is because M1 macs use arm64 as an architecture for iOS simulator, which will conflict in a fat binary since an iOS simulator's arm64 arch is undifferentiated from an iOS device's arm64 arch.

Testing Notes

Follow-up

jurvis commented 2 years ago

@Sjors putting this PR up so you can track my progress with this.

Right now, I've gotten build-libwally.sh to spit out an xcframework for device-only, simulator-only, or both (with https://github.com/ElementsProject/libwally-core/pull/321/commits/59652b58b26adc7cbc290010833a2bca3b848b42 checked out as libwally-core)

Over the coming days I'll test it with Carthage/Cocoapods. Once that's done, you're OK with these changes, and https://github.com/ElementsProject/libwally-core/pull/321 is merged, we can put out a release and everything should work again!

Sjors commented 2 years ago

Thanks! This all sounds great, I'll give it a review soon(tm); I'm just back from the Miami conference, so a bit behind on ... everything.

I like the idea of using the Swift Package Manager, though I suggest a separate PR for that. I might even drop Cocoapods and Carthage once that works, unless there's a good reason other projects can't use the Swift Package Manager.

I just bumped the libwally-core version in #62 (unmerged), so you might want to rebase on that so you can drop 4050ff7cca76dbdc0f356d7b3385f708ff19c732 and 45889941d992c62a69d496188541f8f74161bb85.

Sjors commented 2 years ago

If it makes things easier (see https://github.com/Sjors/libwally-swift/pull/62#issuecomment-1098175785) feel free to create a separate PR that cherry-picks some commits from here.

jurvis commented 2 years ago

@Sjors sorry I need some time to catch up on some school deadlines over the next couple of days. hoping to get this done by this weekend 😄

Sjors commented 2 years ago

Take your time!

By the way, it should be possible to just force push, rather than open a new PR.

jurvis commented 2 years ago

@Sjors oh, yeah. Not sure why I didn’t think of that. Must’ve been late 😅