#!/bin/bash

# Build ProofMode XCFramework for iOS
# Run this script on macOS with Xcode installed

set -e

echo "🔨 Building ProofMode XCFramework for iOS"

# Check prerequisites
if [[ "$OSTYPE" != "darwin"* ]]; then
    echo "❌ This script must be run on macOS"
    exit 1
fi

if ! command -v xcodebuild &> /dev/null; then
    echo "❌ Xcode not found. Please install Xcode from the App Store."
    exit 1
fi

# Build using cargo-make
echo "📦 Building iOS libraries..."
cargo make build-ios

echo "🔧 Generating Swift bindings..."
cargo make generate-ios-bindings

echo "📱 Creating XCFramework..."
cargo make create-xcframework

echo "✅ XCFramework created successfully!"
echo "📍 Location: ./target/xcframework/ProofMode.xcframework"
echo ""
echo "Next steps:"
echo "1. Copy the XCFramework to your iOS project"
echo "2. Add it to your Xcode project"
echo "3. Copy the Swift bindings from ./bindings/ios/"
echo "4. Build and run your iOS app!"
