-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-local-swift.sh
executable file
·53 lines (39 loc) · 2.11 KB
/
build-local-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
#!/bin/bash
# This script builds local Swift language bindings and corresponding portalFFI.xcframework.
# The results of this script can be used for locally testing your SPM package adding a local package
# to your application pointing at the libportal-ios directory.
set -xeo pipefail
# Run the script from the libportal-ios root directory, ie: ./build-local-swift.sh
# rustup install 1.73.0
# rustup component add rust-src
# rustup target add aarch64-apple-ios # iOS ARM64
# rustup target add x86_64-apple-ios # iOS x86_64
# rustup target add aarch64-apple-ios-sim # simulator mac M1
mkdir -p ./Sources/LibPortal
pushd ../
cargo build --features ios,bindings,debug --release --target aarch64-apple-ios
cargo build --features ios,bindings,debug --release --target x86_64-apple-ios
cargo build --features ios,bindings,debug --release --target aarch64-apple-ios-sim
cargo run --bin uniffi-bindgen --features bindings generate --library ../target/aarch64-apple-ios-sim/release/libportal.a --out-dir ./libportal-ios/Sources/LibPortal --language swift --no-format
mkdir -p ../target/lipo-ios-sim/release
lipo ../target/aarch64-apple-ios-sim/release/libportal.a ../target/x86_64-apple-ios/release/libportal.a -create -output ../target/lipo-ios-sim/release/libportal.a
popd
rm -rf ./portalFFI.xcframework
rm -rf ../../target/include
mkdir -pv ../../target/include
cp Sources/LibPortal/portalFFI.h ../../target/include/
cp Sources/LibPortal/portalFFI.modulemap ../../target/include/module.modulemap
# create new xcframework directory from bdk-ffi static libs and headers
xcodebuild -create-xcframework \
-library "../../target/aarch64-apple-ios/release/libportal.a" \
-headers "../../target/include" \
-library "../../target/lipo-ios-sim/release/libportal.a" \
-headers "../../target/include" \
-output "./portalFFI.xcframework"
mv Sources/LibPortal/portal.swift Sources/LibPortal/LibPortal.swift
PACKAGE=${PACKAGE-'0'}
if [ "$PACKAGE" -eq '1' ]; then
find ./portalFFI.xcframework -name ".DS_Store" -exec rm {} \;
rm portalFFI.xcframework.zip || true
zip -9 -r portalFFI.xcframework.zip portalFFI.xcframework
fi