|
| 1 | +#!/bin/bash |
| 2 | +# Build script for iOS XCFramework and Swift bindings for Dojo |
| 3 | + |
| 4 | +set -e |
| 5 | + |
| 6 | +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
| 7 | +PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" |
| 8 | + |
| 9 | +# Colors |
| 10 | +GREEN='\033[0;32m' |
| 11 | +BLUE='\033[0;34m' |
| 12 | +YELLOW='\033[1;33m' |
| 13 | +RED='\033[0;31m' |
| 14 | +NC='\033[0m' |
| 15 | + |
| 16 | +echo -e "${BLUE}=== Building Dojo iOS XCFramework ===${NC}" |
| 17 | +echo "" |
| 18 | + |
| 19 | +# Check for required iOS targets |
| 20 | +echo -e "${YELLOW}Checking iOS targets...${NC}" |
| 21 | +if ! rustup target list --installed | grep -q "aarch64-apple-ios"; then |
| 22 | + echo "Installing aarch64-apple-ios..." |
| 23 | + rustup target add aarch64-apple-ios |
| 24 | +fi |
| 25 | + |
| 26 | +if ! rustup target list --installed | grep -q "aarch64-apple-ios-sim"; then |
| 27 | + echo "Installing aarch64-apple-ios-sim..." |
| 28 | + rustup target add aarch64-apple-ios-sim |
| 29 | +fi |
| 30 | +echo -e "${GREEN}✓ iOS targets ready${NC}" |
| 31 | +echo "" |
| 32 | + |
| 33 | +# Step 1: Build for iOS device (arm64) |
| 34 | +echo -e "${YELLOW}Step 1/4:${NC} Building for iOS device (aarch64-apple-ios)..." |
| 35 | +cd "$PROJECT_ROOT" |
| 36 | +cargo build --release -p dojo-uniffi --target aarch64-apple-ios |
| 37 | +echo -e "${GREEN}✓ iOS device build complete${NC}" |
| 38 | +echo "" |
| 39 | + |
| 40 | +# Step 2: Build for iOS simulator (arm64) |
| 41 | +echo -e "${YELLOW}Step 2/4:${NC} Building for iOS simulator (aarch64-apple-ios-sim)..." |
| 42 | +cargo build --release -p dojo-uniffi --target aarch64-apple-ios-sim |
| 43 | +echo -e "${GREEN}✓ iOS simulator build complete${NC}" |
| 44 | +echo "" |
| 45 | + |
| 46 | +# Step 3: Generate Swift bindings |
| 47 | +echo -e "${YELLOW}Step 3/4:${NC} Generating Swift bindings..." |
| 48 | +./scripts/build_swift.sh |
| 49 | +echo -e "${GREEN}✓ Swift bindings generated${NC}" |
| 50 | +echo "" |
| 51 | + |
| 52 | +# Step 4: Create XCFramework |
| 53 | +echo -e "${YELLOW}Step 4/4:${NC} Creating XCFramework..." |
| 54 | +rm -rf target/dojo_uniffi.xcframework |
| 55 | +xcodebuild -create-xcframework \ |
| 56 | + -library target/aarch64-apple-ios/release/libdojo_uniffi.a \ |
| 57 | + -library target/aarch64-apple-ios-sim/release/libdojo_uniffi.a \ |
| 58 | + -output target/dojo_uniffi.xcframework |
| 59 | +echo -e "${GREEN}✓ XCFramework created${NC}" |
| 60 | +echo "" |
| 61 | + |
| 62 | +echo -e "${GREEN}✅ Build complete!${NC}" |
| 63 | +echo "" |
| 64 | +echo -e "${BLUE}Summary:${NC}" |
| 65 | +echo " • XCFramework: target/dojo_uniffi.xcframework" |
| 66 | +echo " • iOS device: target/aarch64-apple-ios/release/libdojo_uniffi.a" |
| 67 | +echo " • iOS sim: target/aarch64-apple-ios-sim/release/libdojo_uniffi.a" |
| 68 | +echo " • Bindings: bindings/swift/" |
| 69 | +echo "" |
| 70 | + |
0 commit comments