-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_swift.sh
executable file
·58 lines (40 loc) · 2.2 KB
/
build_swift.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash
set -e
# Creates a Swift build of the WalletKitCore library.
# This script is intended to be run in a GitHub Actions workflow.
# When a release is created, the output is committed to the github.com/worldcoin/walletkit-swift repo.
echo "Building WalletKitCore.xcframework"
BASE_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
rm -rf $BASE_PATH/ios_build
rm -rf $BASE_PATH/WalletKitCore.xcframework
mkdir -p $BASE_PATH/ios_build/bindings
mkdir -p $BASE_PATH/ios_build/target/universal-ios-sim/release
mkdir -p $BASE_PATH/Sources/WalletKitCore
export IPHONEOS_DEPLOYMENT_TARGET="13.0"
export RUSTFLAGS="-C link-arg=-Wl,-application_extension"
cargo build --package walletkit-core --target aarch64-apple-ios-sim --release
cargo build --package walletkit-core --target aarch64-apple-ios --release
cargo build --package walletkit-core --target x86_64-apple-ios --release
echo "Rust packages built. Combining into a single binary."
lipo -create target/aarch64-apple-ios-sim/release/libwalletkit_core.a \
target/x86_64-apple-ios/release/libwalletkit_core.a \
-output $BASE_PATH/ios_build/target/universal-ios-sim/release/libwalletkit_core.a
lipo -info $BASE_PATH/ios_build/target/universal-ios-sim/release/libwalletkit_core.a
echo "Generating Swift bindings."
cargo run -p uniffi-bindgen generate \
target/aarch64-apple-ios-sim/release/libwalletkit_core.dylib \
--library \
--language swift \
--no-format \
--out-dir $BASE_PATH/ios_build/bindings
mv $BASE_PATH/ios_build/bindings/walletkit_core.swift $BASE_PATH/Sources/WalletKitCore/
mkdir $BASE_PATH/ios_build/Headers
mkdir -p $BASE_PATH/ios_build/Headers/WalletKitCore
mv $BASE_PATH/ios_build/bindings/walletkit_coreFFI.h $BASE_PATH/ios_build/Headers/WalletKitCore
cat $BASE_PATH/ios_build/bindings/walletkit_coreFFI.modulemap > $BASE_PATH/ios_build/Headers/WalletKitCore/module.modulemap
echo "Creating xcframework."
xcodebuild -create-xcframework \
-library target/aarch64-apple-ios/release/libwalletkit_core.a -headers $BASE_PATH/ios_build/Headers \
-library $BASE_PATH/ios_build/target/universal-ios-sim/release/libwalletkit_core.a -headers $BASE_PATH/ios_build/Headers \
-output $BASE_PATH/WalletKitCore.xcframework
rm -rf $BASE_PATH/ios_build