Skip to content

Commit ecb8d39

Browse files
feat(uniffi): merging issue and prover
Merging a lot of work done by me and Ahmed Moussa Picking the awesome and the awesome in just one repo. This includes: Full issuer functionality and models. Prover issuing functionality and models. Error types. Build scripts for swift. And output swift xcframework for all macos and ios archs
1 parent 2934edd commit ecb8d39

File tree

22 files changed

+1457
-1538
lines changed

22 files changed

+1457
-1538
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#!/bin/bash -e
2+
3+
echo "Verify and install required targets"
4+
targets=(
5+
"x86_64-apple-ios"
6+
"aarch64-apple-ios"
7+
"aarch64-apple-ios-sim"
8+
"aarch64-apple-darwin"
9+
"x86_64-apple-darwin"
10+
)
11+
12+
for target in "${targets[@]}"; do
13+
if ! rustup target list | grep -q "$target (installed)"; then
14+
echo "Target $target is not installed. Installing..."
15+
rustup target add "$target"
16+
echo "Target $target installed."
17+
else
18+
echo "Target $target is already installed."
19+
fi
20+
done
21+
22+
# Create output directories
23+
mkdir -p ./target/universal-ios-sim/release || true
24+
mkdir -p ./target/universal-darwin/release || true
25+
26+
# Generate Uniffi bindings
27+
echo "Creating uniffi bindings"
28+
uniffi-bindgen generate src/anoncreds.udl --language swift -o ./wrappers/swift/anoncreds
29+
30+
# Build targets
31+
echo "Build all targets"
32+
for target in "${targets[@]}"; do
33+
echo "Starting $target build"
34+
cargo build --release --target "$target"
35+
echo "Finished $target build"
36+
done
37+
38+
# Remove existing files in the destination directories
39+
rm -f ./target/universal-ios-sim/release/libanoncreds_uniffi.a || true
40+
rm -f ./target/universal-darwin/release/libanoncreds_uniffi.a || true
41+
rm -dr ./target/universal/libanoncreds.xcframework || true
42+
43+
# Create universal libraries
44+
echo "Creating lipo universal libraries"
45+
lipo -create ./target/aarch64-apple-ios-sim/release/libanoncreds_uniffi.a ./target/x86_64-apple-ios/release/libanoncreds_uniffi.a -output ./target/universal-ios-sim/release/libanoncreds_uniffi.a
46+
47+
lipo -create ./target/aarch64-apple-darwin/release/libanoncreds_uniffi.a ./target/x86_64-apple-darwin/release/libanoncreds_uniffi.a -output ./target/universal-darwin/release/libanoncreds_uniffi.a
48+
49+
# Create XCFramework
50+
echo "Creating xcframework"
51+
xcodebuild -create-xcframework \
52+
-library ./target/aarch64-apple-ios/release/libanoncreds_uniffi.a \
53+
-headers ./wrappers/swift/anoncreds/ \
54+
-library ./target/universal-ios-sim/release/libanoncreds_uniffi.a \
55+
-headers ./wrappers/swift/anoncreds/ \
56+
-library ./target/universal-darwin/release/libanoncreds_uniffi.a \
57+
-headers ./wrappers/swift/anoncreds/ \
58+
-output ./target/universal/libanoncreds.xcframework
59+
60+
echo "Removing .swift files from headers"
61+
dir="./target/universal/libanoncreds.xcframework"
62+
63+
# Compress and copy XCFramework
64+
target_dir_name="libanoncreds.xcframework"
65+
source_dir="./target/universal/"
66+
dest_dir="./output-frameworks/anoncreds-swift"
67+
zip_name="libanoncreds.xcframework.zip"
68+
69+
echo "Zip xcframework"
70+
rm -f "$dest_dir/$zip_name" || true
71+
zip -r "$dest_dir/$zip_name" "$source_dir/$target_dir_name"
72+
73+
echo "Copy .swift binders"
74+
rm -f "./output-frameworks/anoncreds-swift/AnoncredsSwift/Sources/Swift/anoncreds.swift" || true
75+
mv "./wrappers/swift/anoncreds/anoncreds.swift" "./output-frameworks/anoncreds-swift/AnoncredsSwift/Sources/Swift/anoncreds.swift"
76+
77+
rm -f "/wrappers/swift/anoncreds/anoncreds.swift" || true
78+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//
2+
// bridge.c
3+
//
4+
//
5+
// Created by Goncalo Frade IOHK on 30/11/2022.
6+
//
7+
8+
#include "bridge.h"
9+
10+
void __dummy() {}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//
2+
// Header.h
3+
//
4+
//
5+
// Created by Goncalo Frade IOHK on 30/11/2022.
6+
//
7+
8+
#ifndef Header_h
9+
#define Header_h
10+
11+
#include "anoncredsFFI.h"
12+
13+
#endif /* Header_h */

0 commit comments

Comments
 (0)