Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SwiftPM Support #73

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions LibWally.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@

/* Begin PBXFileReference section */
754D4D172811111B00216F1E /* libsecp256k1.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libsecp256k1.a; path = "CLibWally/libwally-core/src/secp256k1/.libs/libsecp256k1.a"; sourceTree = "<group>"; };
757DBE97281E181D00AE30F2 /* Package.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Package.swift; sourceTree = "<group>"; };
75F6BECF281F6F650072D4DE /* LibWallyCore */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = LibWallyCore; path = "CLibWally/libwally-core/build/LibWallyCore"; sourceTree = "<group>"; };
75F6BED0281F6F650072D4DE /* libsecp256k1 */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libsecp256k1; path = "CLibWally/libwally-core/build/libsecp256k1"; sourceTree = "<group>"; };
A20557A522C6CDBE007221AA /* LibWally.modulemap */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = "sourcecode.module-map"; path = LibWally.modulemap; sourceTree = "<group>"; };
Expand Down Expand Up @@ -104,6 +105,7 @@
FE9CD3A7229C397900345DFA = {
isa = PBXGroup;
children = (
757DBE97281E181D00AE30F2 /* Package.swift */,
A20C942622C6BDB000B0D206 /* CLibWally */,
FE39CDF5229D534100DD135E /* DemoPlayground.playground */,
FE9CD3B3229C397900345DFA /* LibWally */,
Expand Down
26 changes: 26 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// swift-tools-version:5.3
import PackageDescription

let tag = "0.0.7"
let checksum = "62aca7cefdf59cfe96d152e12cfd56387e9960e99523527ff478508f70ac25da"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So does this checksum allow others to verify that binary is generated from the code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unfortunately not, the xcframework builds are non-deterministic, so they do change between builds. I'm currently working on a bunch of CI actions so we won't have to do releases manually + users won't have to trust us.

we did something over at https://github.com/lightningdevkit/ldk-swift/actions/runs/2819921873 where we use CI to build releases that...

  1. Generates the XCFramework
  2. Calculates the checksum of the framework from step 1 and use it to modify lines 4 and 5 here
  3. Publishes the release

Though, of course, it does mean that users will have to trust GitHub. But I think it is Good Enough™ to get a SwiftPM option to work nicely, while keeping Cocoapods around for developers who prefer a more "do it yourself" option.

What are your thoughts?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine, as long as we make it clear in the documentation (README?) that using SwiftPM means trusting Github.

let url = "https://github.com/jurvis/libwally-swift/releases/download/\(tag)/LibWally.xcframework.zip"

let package = Package(
name: "LibWally",
platforms: [
.iOS(.v11)
],
products: [
.library(
name: "LibWally",
targets: ["LibWally"]
)
],
targets: [
.binaryTarget(
name: "LibWally",
url: url,
checksum: checksum
)
]
)
7 changes: 7 additions & 0 deletions build-libwally-swift.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ xcodebuild archive -scheme LibWally \
-archivePath ${BIN_OUTPUT_DIRECTORY}/LibWally-Sim \
SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES

# We want to clean the libwally-core static build files for simulator so we can
# build the ones for device.
pushd CLibWally/libwally-core
make clean
rm -rf $(pwd)/build
popd

xcodebuild archive -scheme LibWally \
-destination "generic/platform=iOS" \
-archivePath ${BIN_OUTPUT_DIRECTORY}/LibWally-iOS \
Expand Down