Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ build/
android/src/main/jniLibs/

/macos/frostdart.xcframework/
/ios/libfrostdart.a
33 changes: 17 additions & 16 deletions ios/frostdart.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
#
Pod::Spec.new do |s|
s.name = 'frostdart'
s.version = '0.0.1'
s.summary = 'A new Flutter project.'
s.version = '0.2.0'
s.summary = 'Flutter FFI plugin for FROST threshold signing.'
s.description = <<-DESC
A new Flutter project.
Flutter FFI plugin wrapping the Rust HRF (FROST) crate from
kayabaNerve/serai (a fork of serai-dex/serai) for threshold-signed
Bitcoin wallets.
DESC
s.homepage = 'http://example.com'
s.homepage = 'https://github.com/cypherstack/frostdart'
s.license = { :file => '../LICENSE' }
s.author = { 'Your Company' => 'email@example.com' }
s.author = { 'Cypher Stack' => 'heyo@cypherstack.com' }

# This will ensure the source files in Classes/ are included in the native
# builds of apps using this FFI plugin. Podspec does not support relative
Expand All @@ -20,20 +22,19 @@ A new Flutter project.
s.source = { :path => '.' }
s.source_files = 'Classes/**/*'

s.script_phase = {
:name => 'Build Rust library',
# First argument is relative path to the `rust` folder, second is name of rust library
:script => 'sh "$PODS_TARGET_SRCROOT/../cargokit/build_pod.sh" ../src/serai/hrf frostdart',
:execution_position => :before_compile,
:input_files => ['${BUILT_PRODUCTS_DIR}/cargokit_phony'],
# Let XCode know that the static library referenced in -force_load below is
# created by this build step.
:output_files => ["${BUILT_PRODUCTS_DIR}/libfrostdart.a"],
}
# libfrostdart.a is produced by scripts/ios/download.sh (release artifact)
# or scripts/ios/build_all.sh (build from source). Both drop it next to this
# podspec. Consumers must run one of those before `pod install`.
s.vendored_libraries = 'libfrostdart.a'

s.dependency 'Flutter'
s.platform = :ios, '15.0'

s.pod_target_xcconfig = {
'DEFINES_MODULE' => 'YES',
# Flutter.framework does not contain a i386 slice.
'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386',
'OTHER_LDFLAGS' => '-force_load ${BUILT_PRODUCTS_DIR}/libfrostdart.a',
'OTHER_LDFLAGS' => '-force_load ${PODS_TARGET_SRCROOT}/libfrostdart.a',
}
s.swift_version = '5.0'
end
12 changes: 7 additions & 5 deletions macos/frostdart.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
#
Pod::Spec.new do |s|
s.name = 'frostdart'
s.version = '0.0.1'
s.summary = 'A new Flutter project.'
s.version = '0.2.0'
s.summary = 'Flutter FFI plugin for FROST threshold signing.'
s.description = <<-DESC
A new Flutter project.
Flutter FFI plugin wrapping the Rust HRF (FROST) crate from
kayabaNerve/serai (a fork of serai-dex/serai) for threshold-signed
Bitcoin wallets.
DESC
s.homepage = 'http://example.com'
s.homepage = 'https://github.com/cypherstack/frostdart'
s.license = { :file => '../LICENSE' }
s.author = { 'Your Company' => 'email@example.com' }
s.author = { 'Cypher Stack' => 'heyo@cypherstack.com' }

s.source = { :path => '.' }
s.vendored_frameworks = 'frostdart.xcframework'
Expand Down
6 changes: 3 additions & 3 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: frostdart
description: A new Flutter project.
version: 0.0.1
homepage:
description: Flutter FFI plugin wrapping the Rust HRF (FROST) crate from kayabaNerve/serai (a fork of serai-dex/serai) for threshold-signed Bitcoin wallets.
version: 0.2.0
homepage: https://github.com/cypherstack/frostdart

environment:
sdk: '>=3.0.5 <4.0.0'
Expand Down
19 changes: 13 additions & 6 deletions scripts/ios/build_all.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
#!/bin/bash
set -e

ROOT_DIR="$(pwd)/../.."
LIB_ROOT=../..

mkdir -p build
cd "$LIB_ROOT/src/serai/hrf" || exit

rm -rf "$ROOT_DIR"/src/serai/target
# cargokit's artifact search uses the Cargo package name verbatim, but cargo
# normalizes dashes to underscores in the emitted filename. Rename so cargo's
# output ("libfrostdart.a") and the podspec's vendored_libraries entry agree.
# BSD sed (macOS) syntax; idempotent.
sed -i '' 's/^name = "hrf-api"$/name = "frostdart"/' Cargo.toml

cd "$ROOT_DIR"/src/serai/hrf || exit
export IPHONEOS_DEPLOYMENT_TARGET=15.0
export RUSTFLAGS="-C link-arg=-mios-version-min=15.0"
cargo build --target aarch64-apple-ios --release --lib

# Build is handled by cargokit which requires the rust crate be named the same
sed -i .bak 's/hrf-api/frostdart/' cargo.toml
cp ../target/aarch64-apple-ios/release/libfrostdart.a \
"$LIB_ROOT/ios/libfrostdart.a"
28 changes: 28 additions & 0 deletions scripts/ios/download.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash
set -e

LIB_ROOT=../..
REPO="cypherstack/frostdart"
BASE_URL="https://github.com/${REPO}/releases/download"

TAG=$(git -C "$LIB_ROOT" describe --tags --exact-match HEAD 2>/dev/null) || {
echo "Error: frostdart is not at a tagged commit."
echo "Pin the submodule to a release tag to use download mode."
echo "Current commit: $(git -C "$LIB_ROOT" rev-parse HEAD)"
exit 1
}

TMPDIR=$(mktemp -d)
trap 'rm -rf "$TMPDIR"' EXIT

curl -fSL "${BASE_URL}/${TAG}/checksums.txt" -o "$TMPDIR/checksums.txt"

download_and_verify() {
local asset="$1"
curl -fSL "${BASE_URL}/${TAG}/${asset}" -o "$TMPDIR/${asset}"
grep "^[0-9a-f]* ${asset}$" "$TMPDIR/checksums.txt" | (cd "$TMPDIR" && shasum -a 256 -c)
}

download_and_verify "frostdart-ios-aarch64.a"

cp "$TMPDIR/frostdart-ios-aarch64.a" "$LIB_ROOT/ios/libfrostdart.a"