
Some checks are pending
iOS UniFFI Build / build-ios (push) Waiting to run
Add church management API library with cross-platform support for iOS, Android, and WASM. Features include event management, bulletin handling, contact forms, and authentication.
114 lines
4 KiB
Bash
Executable file
114 lines
4 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
# UniFFI iOS Build Script
|
|
# Generates Swift bindings and universal iOS framework without Python dependencies
|
|
|
|
set -e
|
|
|
|
echo "🔨 Building UniFFI iOS Framework..."
|
|
|
|
# Clean previous builds
|
|
echo "🧹 Cleaning previous builds..."
|
|
rm -rf target/
|
|
rm -rf bindings/
|
|
mkdir -p bindings/ios
|
|
|
|
# Install uniffi_bindgen if not present
|
|
if ! command -v uniffi-bindgen &> /dev/null; then
|
|
echo "📦 Installing uniffi_bindgen..."
|
|
cargo install uniffi_bindgen --bin uniffi-bindgen
|
|
fi
|
|
|
|
# iOS and Mac Catalyst targets
|
|
IOS_TARGETS=(
|
|
"aarch64-apple-ios" # iOS device (ARM64)
|
|
"aarch64-apple-ios-sim" # iOS simulator (Apple Silicon)
|
|
"aarch64-apple-ios-macabi" # Mac Catalyst (Apple Silicon)
|
|
"x86_64-apple-ios-macabi" # Mac Catalyst (Intel)
|
|
)
|
|
|
|
echo "📱 Installing iOS targets..."
|
|
for target in "${IOS_TARGETS[@]}"; do
|
|
rustup target add "$target"
|
|
done
|
|
|
|
echo "🔧 Building Rust library for iOS targets..."
|
|
for target in "${IOS_TARGETS[@]}"; do
|
|
echo "Building for $target..."
|
|
cargo build --release --target "$target" --features uniffi
|
|
done
|
|
|
|
echo "⚡ Generating Swift bindings..."
|
|
# Generate Swift bindings using uniffi_bindgen
|
|
uniffi-bindgen generate \
|
|
src/church_core.udl \
|
|
--language swift \
|
|
--out-dir bindings/ios \
|
|
--lib-file target/aarch64-apple-ios/release/libchurch_core.a
|
|
|
|
echo "📋 Generating module map..."
|
|
# Create module map for Swift integration
|
|
cat > bindings/ios/church_coreFFI.modulemap << EOF
|
|
module church_coreFFI {
|
|
header "church_coreFFI.h"
|
|
export *
|
|
}
|
|
EOF
|
|
|
|
echo "🔗 Preparing libraries..."
|
|
# Simulator library (Apple Silicon only)
|
|
cp target/aarch64-apple-ios-sim/release/libchurch_core.a bindings/ios/libchurch_core_sim.a
|
|
|
|
# Device library (ARM64 device)
|
|
cp target/aarch64-apple-ios/release/libchurch_core.a bindings/ios/libchurch_core_device.a
|
|
|
|
# Mac Catalyst libraries
|
|
cp target/aarch64-apple-ios-macabi/release/libchurch_core.a bindings/ios/libchurch_core_mac_arm64.a
|
|
cp target/x86_64-apple-ios-macabi/release/libchurch_core.a bindings/ios/libchurch_core_mac_x86_64.a
|
|
|
|
# Create universal Mac Catalyst library
|
|
lipo -create \
|
|
bindings/ios/libchurch_core_mac_arm64.a \
|
|
bindings/ios/libchurch_core_mac_x86_64.a \
|
|
-output bindings/ios/libchurch_core_mac_catalyst.a
|
|
|
|
echo "🔗 Creating XCFramework..."
|
|
# Create separate header directories for each library
|
|
mkdir -p bindings/ios/device-headers
|
|
mkdir -p bindings/ios/sim-headers
|
|
mkdir -p bindings/ios/mac-arm64-headers
|
|
mkdir -p bindings/ios/mac-x86_64-headers
|
|
cp bindings/ios/church_coreFFI.h bindings/ios/device-headers/
|
|
cp bindings/ios/church_coreFFI.h bindings/ios/sim-headers/
|
|
cp bindings/ios/church_coreFFI.h bindings/ios/mac-arm64-headers/
|
|
cp bindings/ios/church_coreFFI.h bindings/ios/mac-x86_64-headers/
|
|
|
|
# Create XCFramework with Mac Catalyst support
|
|
# Using universal Mac Catalyst library built from -macabi targets
|
|
xcodebuild -create-xcframework \
|
|
-library bindings/ios/libchurch_core_device.a \
|
|
-headers bindings/ios/device-headers \
|
|
-library bindings/ios/libchurch_core_sim.a \
|
|
-headers bindings/ios/sim-headers \
|
|
-library bindings/ios/libchurch_core_mac_catalyst.a \
|
|
-headers bindings/ios/mac-arm64-headers \
|
|
-output bindings/ios/ChurchCore.xcframework
|
|
|
|
echo "📦 Moving files to iOS project..."
|
|
# Copy generated files to iOS project
|
|
IOS_PROJECT_DIR="../RTSDA-iOS/RTSDA"
|
|
cp bindings/ios/church_core.swift "$IOS_PROJECT_DIR/"
|
|
cp bindings/ios/church_coreFFI.h "$IOS_PROJECT_DIR/"
|
|
cp bindings/ios/church_coreFFI.modulemap "$IOS_PROJECT_DIR/"
|
|
cp -r bindings/ios/ChurchCore.xcframework "$IOS_PROJECT_DIR/"
|
|
|
|
echo "✅ UniFFI iOS framework build complete!"
|
|
echo "📁 Generated files:"
|
|
echo " - church_core.swift (Swift bindings)"
|
|
echo " - church_coreFFI.h (C header)"
|
|
echo " - church_coreFFI.modulemap (Module map)"
|
|
echo " - ChurchCore.xcframework (Universal XCFramework)"
|
|
echo ""
|
|
echo "🎯 Files copied to: $IOS_PROJECT_DIR"
|
|
echo "💡 Add ChurchCore.xcframework to your Xcode project and you're good to go!"
|
|
echo "📱 Supports: iOS Device (ARM64), iOS Simulator (Apple Silicon), Mac Catalyst (Intel + Apple Silicon)" |