feat: iOS XCFramework build - device + simulator static libs

This commit is contained in:
wangdl 2026-06-01 20:09:29 +08:00
parent ddcc5b392c
commit 6a0ac9c15c
6 changed files with 87 additions and 0 deletions

View File

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>AvailableLibraries</key>
<array>
<dict>
<key>BinaryPath</key>
<string>libzx_document_ffi.a</string>
<key>LibraryIdentifier</key>
<string>ios-arm64</string>
<key>LibraryPath</key>
<string>libzx_document_ffi.a</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
</dict>
<dict>
<key>BinaryPath</key>
<string>libzx_document_ffi.a</string>
<key>LibraryIdentifier</key>
<string>ios-arm64-simulator</string>
<key>LibraryPath</key>
<string>libzx_document_ffi.a</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
</array>
<key>CFBundlePackageType</key>
<string>XFWK</string>
<key>XCFrameworkFormatVersion</key>
<string>1.0</string>
</dict>
</plist>

Binary file not shown.

Binary file not shown.

44
scripts/build-ios.sh Executable file
View File

@ -0,0 +1,44 @@
#!/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/"