45 lines
1.4 KiB
Bash
Executable File
45 lines
1.4 KiB
Bash
Executable File
#!/bin/bash
|
|
# Build iOS XCFramework for zhixi-document-runtime
|
|
set -e
|
|
|
|
RUST_DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
|
OUT_DIR="$RUST_DIR/bindings/ios"
|
|
LIB_NAME="libzx_document_ffi.a"
|
|
MODULE_NAME="ZxDocumentRuntime"
|
|
|
|
# Ensure iOS targets are installed
|
|
rustup target add aarch64-apple-ios aarch64-apple-ios-sim
|
|
|
|
echo "==> Building for iOS device (arm64)..."
|
|
cargo build --release --target aarch64-apple-ios
|
|
|
|
echo "==> Building for iOS simulator (arm64)..."
|
|
cargo build --release --target aarch64-apple-ios-sim
|
|
|
|
# Prepare output
|
|
rm -rf "$OUT_DIR/ZxDocumentRuntime.xcframework"
|
|
mkdir -p "$OUT_DIR/device" "$OUT_DIR/simulator" "$OUT_DIR/generated"
|
|
|
|
# Copy libraries
|
|
cp "target/aarch64-apple-ios/release/$LIB_NAME" "$OUT_DIR/device/"
|
|
cp "target/aarch64-apple-ios-sim/release/$LIB_NAME" "$OUT_DIR/simulator/"
|
|
|
|
# Generate Swift bindings
|
|
echo "==> Generating Swift bindings..."
|
|
uniffi-bindgen-swift \
|
|
--module-name "$MODULE_NAME" \
|
|
--swift-sources \
|
|
"$RUST_DIR/crates/zx_document_ffi/src/zx_document.udl" \
|
|
"$OUT_DIR/generated"
|
|
|
|
# Create XCFramework
|
|
echo "==> Creating XCFramework..."
|
|
xcodebuild -create-xcframework \
|
|
-library "$OUT_DIR/device/$LIB_NAME" \
|
|
-library "$OUT_DIR/simulator/$LIB_NAME" \
|
|
-output "$OUT_DIR/ZxDocumentRuntime.xcframework"
|
|
|
|
echo "==> Done!"
|
|
echo "XCFramework: $OUT_DIR/ZxDocumentRuntime.xcframework"
|
|
echo "Swift sources: $OUT_DIR/generated/"
|