
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.
105 lines
3.2 KiB
Bash
Executable file
105 lines
3.2 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
# UniFFI iOS and tvOS Build Script using -Zbuild-std
|
|
# Uses nightly cargo with -Zbuild-std to build tvOS targets
|
|
|
|
set -e
|
|
|
|
echo "🔨 Building UniFFI iOS and tvOS Framework with -Zbuild-std..."
|
|
|
|
# Clean previous builds
|
|
echo "🧹 Cleaning previous builds..."
|
|
rm -rf target/
|
|
rm -rf bindings/
|
|
mkdir -p bindings/ios
|
|
|
|
# Install nightly toolchain
|
|
echo "🌙 Installing nightly toolchain..."
|
|
rustup toolchain install nightly
|
|
rustup component add rust-src --toolchain nightly
|
|
|
|
# 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 targets (stable)
|
|
IOS_TARGETS=(
|
|
"aarch64-apple-ios" # iOS device (ARM64)
|
|
"x86_64-apple-ios" # iOS simulator (Intel)
|
|
)
|
|
|
|
# tvOS targets (require -Zbuild-std)
|
|
TVOS_TARGETS=(
|
|
"aarch64-apple-tvos" # tvOS device (ARM64)
|
|
"x86_64-apple-tvos" # tvOS simulator (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 "📺 Building Rust library for tvOS targets with -Zbuild-std..."
|
|
for target in "${TVOS_TARGETS[@]}"; do
|
|
echo "Building for $target..."
|
|
cargo +nightly build --release --target "$target" --features uniffi -Zbuild-std
|
|
done
|
|
|
|
echo "🔗 Creating separate libraries..."
|
|
|
|
# iOS universal library
|
|
lipo -create \
|
|
target/aarch64-apple-ios/release/libchurch_core.a \
|
|
target/x86_64-apple-ios/release/libchurch_core.a \
|
|
-output bindings/ios/libchurch_core_ios.a
|
|
|
|
# tvOS universal library
|
|
lipo -create \
|
|
target/aarch64-apple-tvos/release/libchurch_core.a \
|
|
target/x86_64-apple-tvos/release/libchurch_core.a \
|
|
-output bindings/ios/libchurch_core_tvos.a
|
|
|
|
# Default to iOS library
|
|
cp bindings/ios/libchurch_core_ios.a bindings/ios/libchurch_core_universal.a
|
|
|
|
echo "⚡ Generating Swift bindings..."
|
|
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..."
|
|
cat > bindings/ios/church_coreFFI.modulemap << EOF
|
|
module church_coreFFI {
|
|
header "church_coreFFI.h"
|
|
export *
|
|
}
|
|
EOF
|
|
|
|
echo "📦 Moving 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 bindings/ios/libchurch_core_universal.a "$IOS_PROJECT_DIR/libchurch_core.a"
|
|
|
|
# Also copy the separate libraries for manual swapping if needed
|
|
cp bindings/ios/libchurch_core_ios.a "$IOS_PROJECT_DIR/"
|
|
cp bindings/ios/libchurch_core_tvos.a "$IOS_PROJECT_DIR/"
|
|
|
|
echo "✅ UniFFI iOS and tvOS framework build complete!"
|
|
echo "📁 Generated separate libraries:"
|
|
echo " - libchurch_core.a (default: iOS)"
|
|
echo " - libchurch_core_ios.a (iOS only)"
|
|
echo " - libchurch_core_tvos.a (tvOS only)"
|
|
echo "🎯 Files copied to: $IOS_PROJECT_DIR"
|
|
echo "💡 If tvOS build fails, manually swap to libchurch_core_tvos.a" |