
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.
124 lines
4.1 KiB
Bash
Executable file
124 lines
4.1 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
# UniFFI iOS and tvOS Build Script
|
|
# Generates Swift bindings and universal framework for both iOS and tvOS
|
|
|
|
set -e
|
|
|
|
echo "🔨 Building UniFFI iOS and tvOS Framework..."
|
|
|
|
# Clean previous builds
|
|
echo "🧹 Cleaning previous builds..."
|
|
rm -rf target/
|
|
rm -rf bindings/
|
|
mkdir -p bindings/ios
|
|
|
|
# Install nightly toolchain for tvOS support
|
|
echo "🌙 Installing nightly toolchain for tvOS support..."
|
|
rustup toolchain install nightly
|
|
rustup component add rust-std --toolchain nightly --target aarch64-apple-tvos
|
|
rustup component add rust-std --toolchain nightly --target aarch64-apple-tvos-sim
|
|
rustup component add rust-std --toolchain nightly --target x86_64-apple-tvos
|
|
|
|
# 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
|
|
IOS_TARGETS=(
|
|
"aarch64-apple-ios" # iOS device (ARM64)
|
|
"x86_64-apple-ios" # iOS simulator (Intel)
|
|
)
|
|
|
|
# tvOS targets
|
|
TVOS_TARGETS=(
|
|
"aarch64-apple-tvos" # tvOS device (ARM64)
|
|
"aarch64-apple-tvos-sim" # tvOS simulator (Apple Silicon)
|
|
"x86_64-apple-tvos" # tvOS simulator (Intel)
|
|
)
|
|
|
|
echo "📱 Installing iOS targets..."
|
|
for target in "${IOS_TARGETS[@]}"; do
|
|
rustup target add "$target"
|
|
done
|
|
|
|
echo "📺 Installing tvOS targets..."
|
|
for target in "${TVOS_TARGETS[@]}"; do
|
|
rustup target add "$target" --toolchain nightly
|
|
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..."
|
|
for target in "${TVOS_TARGETS[@]}"; do
|
|
echo "Building for $target..."
|
|
cargo +nightly build --release --target "$target" --features uniffi
|
|
done
|
|
|
|
echo "🔗 Creating universal libraries..."
|
|
|
|
# Create 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
|
|
|
|
# Create tvOS universal library
|
|
lipo -create \
|
|
target/aarch64-apple-tvos/release/libchurch_core.a \
|
|
target/aarch64-apple-tvos-sim/release/libchurch_core.a \
|
|
target/x86_64-apple-tvos/release/libchurch_core.a \
|
|
-output bindings/ios/libchurch_core_tvos.a
|
|
|
|
# Create combined universal library for Xcode (it will pick the right slice)
|
|
lipo -create \
|
|
target/aarch64-apple-ios/release/libchurch_core.a \
|
|
target/x86_64-apple-ios/release/libchurch_core.a \
|
|
target/aarch64-apple-tvos/release/libchurch_core.a \
|
|
target/x86_64-apple-tvos/release/libchurch_core.a \
|
|
-output bindings/ios/libchurch_core_universal.a
|
|
|
|
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 "📦 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 bindings/ios/libchurch_core_universal.a "$IOS_PROJECT_DIR/libchurch_core.a"
|
|
|
|
echo "✅ UniFFI iOS and tvOS 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 " - libchurch_core.a (Universal static library - iOS + tvOS)"
|
|
echo ""
|
|
echo "🎯 Files copied to: $IOS_PROJECT_DIR"
|
|
echo "💡 You can now build your iOS/tvOS project in Xcode!"
|
|
echo ""
|
|
echo "📺 Libraries also available separately:"
|
|
echo " - bindings/ios/libchurch_core_ios.a (iOS only)"
|
|
echo " - bindings/ios/libchurch_core_tvos.a (tvOS only)" |