From 0afe80ca8d9bcba8636a142091e3c095329bd9a7 Mon Sep 17 00:00:00 2001 From: RTSDA Date: Sat, 16 Aug 2025 19:28:17 -0400 Subject: [PATCH] Clean up repository structure Move build scripts, test scripts, examples, and generated files to scripts/ directory. Update .gitignore to exclude scripts/ from future commits to keep repository clean. --- .gitignore | 5 +- build.sh | 32 -------- build_android.sh | 120 ------------------------------ build_ios.sh | 114 ---------------------------- build_ios_tvos.sh | 124 ------------------------------- build_tvos_zbuild.sh | 105 -------------------------- generate_bindings.rs | 24 ------ generate_kotlin_bindings.sh | 144 ------------------------------------ simple_build.sh | 40 ---------- swift_usage_example.swift | 138 ---------------------------------- test_config_functions.rs | 39 ---------- test_sermon_json.rs | 31 -------- 12 files changed, 4 insertions(+), 912 deletions(-) delete mode 100755 build.sh delete mode 100755 build_android.sh delete mode 100755 build_ios.sh delete mode 100755 build_ios_tvos.sh delete mode 100755 build_tvos_zbuild.sh delete mode 100644 generate_bindings.rs delete mode 100755 generate_kotlin_bindings.sh delete mode 100755 simple_build.sh delete mode 100644 swift_usage_example.swift delete mode 100644 test_config_functions.rs delete mode 100644 test_sermon_json.rs diff --git a/.gitignore b/.gitignore index 7f6e61b..351b1dd 100644 --- a/.gitignore +++ b/.gitignore @@ -40,4 +40,7 @@ coverage/ # Temporary files *.tmp -*.temp \ No newline at end of file +*.temp + +# Scripts directory (build scripts, test scripts, examples) +scripts/ \ No newline at end of file diff --git a/build.sh b/build.sh deleted file mode 100755 index 4c204f9..0000000 --- a/build.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash -set -e - -echo "Building iOS framework with UniFFI..." - -# Add iOS targets -rustup target add aarch64-apple-ios -rustup target add aarch64-apple-ios-sim -rustup target add x86_64-apple-ios - -# Build for iOS targets -cargo build --release --target aarch64-apple-ios --features uniffi -cargo build --release --target aarch64-apple-ios-sim --features uniffi -cargo build --release --target x86_64-apple-ios --features uniffi - -# Create universal library -mkdir -p target/universal -lipo -create \ - target/aarch64-apple-ios/release/libchurch_core.a \ - target/aarch64-apple-ios-sim/release/libchurch_core.a \ - target/x86_64-apple-ios/release/libchurch_core.a \ - -output target/universal/libchurch_core.a - -# Generate Swift bindings using cargo (this should work!) -cargo run --features uniffi --bin uniffi-bindgen generate --language swift --out-dir target/universal src/church_core.udl - -# Copy to iOS project -cp target/universal/church_core.swift ../RTSDA-iOS/RTSDA/ -cp target/universal/church_coreFFI.h ../RTSDA-iOS/RTSDA/ -cp target/universal/libchurch_core.a ../RTSDA-iOS/RTSDA/ - -echo "Done! Generated files copied to iOS project." \ No newline at end of file diff --git a/build_android.sh b/build_android.sh deleted file mode 100755 index 7a76e50..0000000 --- a/build_android.sh +++ /dev/null @@ -1,120 +0,0 @@ -#!/bin/bash - -# UniFFI Android Build Script -# Generates Kotlin bindings and Android libraries - -set -e - -echo "๐Ÿค– Building UniFFI Android Library..." - -# Clean previous Android builds -echo "๐Ÿงน Cleaning previous Android builds..." -rm -rf bindings/android/ -mkdir -p bindings/android - -# Install required tools -if ! command -v uniffi-bindgen &> /dev/null; then - echo "๐Ÿ“ฆ Installing uniffi_bindgen..." - cargo install uniffi_bindgen --bin uniffi-bindgen -fi - -if ! command -v cargo-ndk &> /dev/null; then - echo "๐Ÿ“ฆ Installing cargo-ndk..." - cargo install cargo-ndk -fi - -# Android targets for cargo-ndk -ANDROID_ABIS=( - "arm64-v8a" # ARM64 devices - "armeabi-v7a" # ARM32 devices - "x86_64" # x86_64 emulator - "x86" # x86 emulator -) - -echo "๐Ÿ”ง Building Rust library for Android targets using cargo-ndk..." -for abi in "${ANDROID_ABIS[@]}"; do - echo "Building for $abi..." - cargo ndk --target $abi --platform 21 build --release --features uniffi -done - -echo "โšก Generating Kotlin bindings..." -# Find the first available library for binding generation -if [ -f "target/aarch64-linux-android/release/libchurch_core.so" ]; then - LIB_FILE="target/aarch64-linux-android/release/libchurch_core.so" -else - # Find any available library - LIB_FILE=$(find target -name "libchurch_core.so" -type f | head -1) -fi - -# Generate Kotlin bindings using uniffi_bindgen -uniffi-bindgen generate \ - src/church_core.udl \ - --language kotlin \ - --out-dir bindings/android \ - --lib-file "$LIB_FILE" - -echo "๐Ÿ“ Organizing Android libraries..." -# Create JNI library structure -mkdir -p bindings/android/jniLibs/arm64-v8a -mkdir -p bindings/android/jniLibs/armeabi-v7a -mkdir -p bindings/android/jniLibs/x86_64 -mkdir -p bindings/android/jniLibs/x86 - -# Copy libraries to JNI structure (cargo-ndk puts them in different locations) -if [ -f "target/aarch64-linux-android/release/libchurch_core.so" ]; then - cp target/aarch64-linux-android/release/libchurch_core.so bindings/android/jniLibs/arm64-v8a/ -fi -if [ -f "target/armv7-linux-androideabi/release/libchurch_core.so" ]; then - cp target/armv7-linux-androideabi/release/libchurch_core.so bindings/android/jniLibs/armeabi-v7a/ -fi -if [ -f "target/x86_64-linux-android/release/libchurch_core.so" ]; then - cp target/x86_64-linux-android/release/libchurch_core.so bindings/android/jniLibs/x86_64/ -fi -if [ -f "target/i686-linux-android/release/libchurch_core.so" ]; then - cp target/i686-linux-android/release/libchurch_core.so bindings/android/jniLibs/x86/ -fi - -echo "๐Ÿ“ฆ Creating Android README..." -cat > bindings/android/README.md << EOF -# Church Core Android Bindings - -This directory contains the generated Kotlin bindings and native libraries for the church-core Rust crate. - -## Files: -- \`uniffi/\` - Generated Kotlin bindings -- \`jniLibs/\` - Native libraries for Android architectures - - \`arm64-v8a/\` - ARM64 devices (modern phones) - - \`armeabi-v7a/\` - ARM32 devices (older phones) - - \`x86_64/\` - x86_64 emulator - - \`x86/\` - x86 emulator - -## Integration: -1. Copy the Kotlin files from \`uniffi/\` to your Android project's \`src/main/java/\` directory -2. Copy the \`jniLibs/\` directory to your Android project's \`src/main/\` directory -3. Add JNA dependency to your \`build.gradle\`: - ```gradle - implementation 'net.java.dev.jna:jna:5.13.0@aar' - ``` - -## Usage: -```kotlin -import uniffi.church_core.* - -// Fetch events -val eventsJson = fetchEventsJson() - -// Fetch sermons -val sermonsJson = fetchSermonsJson() - -// All other functions from the UDL file are available -``` -EOF - -echo "โœ… UniFFI Android library build complete!" -echo "๐Ÿ“ Generated files in bindings/android/:" -echo " - uniffi/ (Kotlin bindings)" -echo " - jniLibs/ (Native libraries for all Android architectures)" -echo " - README.md (Integration instructions)" -echo "" -echo "๐ŸŽฏ Ready for Android integration!" -echo "๐Ÿ’ก Follow the README.md instructions to integrate into your Android project" \ No newline at end of file diff --git a/build_ios.sh b/build_ios.sh deleted file mode 100755 index 2b30308..0000000 --- a/build_ios.sh +++ /dev/null @@ -1,114 +0,0 @@ -#!/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)" \ No newline at end of file diff --git a/build_ios_tvos.sh b/build_ios_tvos.sh deleted file mode 100755 index 2f946b4..0000000 --- a/build_ios_tvos.sh +++ /dev/null @@ -1,124 +0,0 @@ -#!/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)" \ No newline at end of file diff --git a/build_tvos_zbuild.sh b/build_tvos_zbuild.sh deleted file mode 100755 index b44326f..0000000 --- a/build_tvos_zbuild.sh +++ /dev/null @@ -1,105 +0,0 @@ -#!/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" \ No newline at end of file diff --git a/generate_bindings.rs b/generate_bindings.rs deleted file mode 100644 index f621195..0000000 --- a/generate_bindings.rs +++ /dev/null @@ -1,24 +0,0 @@ -use std::path::Path; -use uniffi_bindgen::library_mode::generate_bindings; - -fn main() -> Result<(), Box> { - let lib_path = "target/aarch64-apple-ios/release/libchurch_core.a"; - let out_dir = Path::new("bindings/ios"); - - // Create output directory if it doesn't exist - std::fs::create_dir_all(out_dir)?; - - // Generate Swift bindings - generate_bindings( - &uniffi_bindgen::bindings::swift::SwiftBindingGenerator, - lib_path, - None, // no UDL file - None, // default config - None, // no config file - out_dir, - false, // not a library mode - )?; - - println!("Swift bindings generated in {:?}", out_dir); - Ok(()) -} \ No newline at end of file diff --git a/generate_kotlin_bindings.sh b/generate_kotlin_bindings.sh deleted file mode 100755 index 25e083f..0000000 --- a/generate_kotlin_bindings.sh +++ /dev/null @@ -1,144 +0,0 @@ -#!/bin/bash - -# Generate Kotlin bindings only (without native compilation) -# This gives you the Kotlin interface code to use when you set up Android development - -set -e - -echo "๐Ÿค– Generating Kotlin bindings for Android..." - -# Clean previous Android bindings -echo "๐Ÿงน Cleaning previous Android bindings..." -rm -rf bindings/android/ -mkdir -p bindings/android - -# 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 - -echo "โšก Generating Kotlin bindings..." -# Use an existing iOS library file for binding generation (they're compatible) -if [ -f "bindings/ios/libchurch_core_device.a" ]; then - LIB_FILE="bindings/ios/libchurch_core_device.a" -elif [ -f "target/aarch64-apple-ios/release/libchurch_core.a" ]; then - LIB_FILE="target/aarch64-apple-ios/release/libchurch_core.a" -else - echo "โŒ No existing library found. Please run ./build_ios.sh first." - exit 1 -fi - -# Generate Kotlin bindings using uniffi_bindgen -uniffi-bindgen generate \ - src/church_core.udl \ - --language kotlin \ - --out-dir bindings/android \ - --lib-file "$LIB_FILE" - -echo "๐Ÿ“ฆ Creating Android integration README..." -cat > bindings/android/README.md << 'EOF' -# Church Core Android Bindings - -This directory contains the generated Kotlin bindings for the church-core Rust crate. - -## Files: -- `uniffi/church_core/` - Generated Kotlin bindings - -## What's Missing: -- Native libraries (.so files) - You need to compile these with Android NDK -- JNI library structure - Will be created when you compile native libraries - -## To Complete Android Setup: - -### 1. Install Android Development Tools: -```bash -# Install Android SDK/NDK (via Android Studio or command line tools) -# Set environment variables: -export ANDROID_SDK_ROOT=/path/to/android/sdk -export ANDROID_NDK_HOME=$ANDROID_SDK_ROOT/ndk/[version] -``` - -### 2. Install cargo-ndk: -```bash -cargo install cargo-ndk -``` - -### 3. Build native libraries: -```bash -# From church-core directory -cargo ndk --target arm64-v8a --platform 21 build --release --features uniffi -cargo ndk --target armeabi-v7a --platform 21 build --release --features uniffi -cargo ndk --target x86_64 --platform 21 build --release --features uniffi -cargo ndk --target x86 --platform 21 build --release --features uniffi -``` - -### 4. Create JNI structure: -```bash -mkdir -p jniLibs/{arm64-v8a,armeabi-v7a,x86_64,x86} -cp target/aarch64-linux-android/release/libchurch_core.so jniLibs/arm64-v8a/ -cp target/armv7-linux-androideabi/release/libchurch_core.so jniLibs/armeabi-v7a/ -cp target/x86_64-linux-android/release/libchurch_core.so jniLibs/x86_64/ -cp target/i686-linux-android/release/libchurch_core.so jniLibs/x86/ -``` - -## Integration in Android Project: - -### 1. Add JNA dependency to your `build.gradle`: -```gradle -implementation 'net.java.dev.jna:jna:5.13.0@aar' -``` - -### 2. Copy files to your Android project: -- Copy `uniffi/church_core/` to `src/main/java/` -- Copy `jniLibs/` to `src/main/` - -### 3. Usage in Kotlin: -```kotlin -import uniffi.church_core.* - -class ChurchRepository { - fun fetchEvents(): String { - return fetchEventsJson() - } - - fun fetchSermons(): String { - return fetchSermonsJson() - } - - fun fetchBulletins(): String { - return fetchBulletinsJson() - } - - // All other functions from the UDL file are available -} -``` - -## Functions Available: -All functions defined in `src/church_core.udl` are available in Kotlin: -- `fetchEventsJson()` -- `fetchSermonsJson()` -- `fetchBulletinsJson()` -- `fetchBibleVerseJson(query: String)` -- `fetchRandomBibleVerseJson()` -- `submitContactV2Json(...)` -- `fetchCachedImageBase64(url: String)` -- `getOptimalStreamingUrl(mediaId: String)` -- `parseEventsFromJson(eventsJson: String)` -- `parseSermonsFromJson(sermonsJson: String)` -- And many more... - -## Architecture Notes: -- All business logic is in Rust (networking, parsing, validation, etc.) -- Kotlin only handles UI and calls Rust functions -- Same RTSDA architecture as iOS version -- JSON responses from Rust, parse to data classes in Kotlin -EOF - -echo "โœ… Kotlin bindings generated!" -echo "๐Ÿ“ Generated files in bindings/android/:" -ls -la bindings/android/ -echo "" -echo "๐Ÿ“– See bindings/android/README.md for integration instructions" -echo "๐Ÿ’ก You'll need Android SDK/NDK to compile the native libraries" -echo "๐ŸŽฏ But the Kotlin interface code is ready to use!" \ No newline at end of file diff --git a/simple_build.sh b/simple_build.sh deleted file mode 100755 index cc68c47..0000000 --- a/simple_build.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash -set -e - -echo "๐Ÿ”จ Simple UniFFI iOS build..." - -# Add targets if needed -rustup target add aarch64-apple-ios aarch64-apple-ios-sim x86_64-apple-ios - -# Build for all iOS targets -echo "Building for iOS..." -cargo build --release --target aarch64-apple-ios --features uniffi -cargo build --release --target aarch64-apple-ios-sim --features uniffi -cargo build --release --target x86_64-apple-ios --features uniffi - -# Create fat binary (iOS device + Intel simulator, skip ARM sim for now) -echo "Creating universal library..." -lipo -create \ - target/aarch64-apple-ios/release/libchurch_core.a \ - target/x86_64-apple-ios/release/libchurch_core.a \ - -output libchurch_core_universal.a - -# Generate bindings directly with uniffi_bindgen -echo "Generating Swift bindings..." -uniffi-bindgen generate src/church_core.udl --language swift --out-dir . - -# Copy everything to iOS project -echo "Copying to iOS project..." -cp church_core.swift ../RTSDA-iOS/RTSDA/ -cp church_coreFFI.h ../RTSDA-iOS/RTSDA/ -cp libchurch_core_universal.a ../RTSDA-iOS/RTSDA/libchurch_core.a - -# Create modulemap -cat > ../RTSDA-iOS/RTSDA/church_coreFFI.modulemap << EOF -module church_coreFFI { - header "church_coreFFI.h" - export * -} -EOF - -echo "โœ… Done! Build your iOS app in Xcode." \ No newline at end of file diff --git a/swift_usage_example.swift b/swift_usage_example.swift deleted file mode 100644 index 5154813..0000000 --- a/swift_usage_example.swift +++ /dev/null @@ -1,138 +0,0 @@ -// Swift Usage Example for New Config Functions -// This shows how to use the new RTSDA-compliant config functions in iOS - -import Foundation - -// WRONG - Old way (violates RTSDA architecture) -/* -private func loadChurchConfig() { - let configJson = fetchConfigJson() // Gets raw JSON from Rust - - // THIS IS BUSINESS LOGIC AND SHOULD BE IN RUST! - if let configData = configJson.data(using: .utf8), - let config = try? JSONDecoder().decode(ChurchConfig.self, from: configData) { - self.churchConfig = config - } else { - print("Failed to load church config") - } -} -*/ - -// RIGHT - New way (follows RTSDA architecture) -class ChurchConfigManager: ObservableObject { - @Published var churchName: String = "" - @Published var contactPhone: String = "" - @Published var contactEmail: String = "" - @Published var brandColor: String = "" - @Published var aboutText: String = "" - @Published var donationUrl: String = "" - @Published var churchAddress: String = "" - @Published var coordinates: [Double] = [0.0, 0.0] - @Published var websiteUrl: String = "" - @Published var facebookUrl: String = "" - @Published var youtubeUrl: String = "" - @Published var instagramUrl: String = "" - @Published var missionStatement: String = "" - - func loadConfig() { - // ALL business logic (JSON parsing, error handling, fallbacks) is in Rust - // Swift just calls Rust functions and gets parsed values directly - self.churchName = getChurchName() - self.contactPhone = getContactPhone() - self.contactEmail = getContactEmail() - self.brandColor = getBrandColor() - self.aboutText = getAboutText() - self.donationUrl = getDonationUrl() - self.churchAddress = getChurchAddress() - self.coordinates = getCoordinates() - self.websiteUrl = getWebsiteUrl() - self.facebookUrl = getFacebookUrl() - self.youtubeUrl = getYoutubeUrl() - self.instagramUrl = getInstagramUrl() - self.missionStatement = getMissionStatement() - } -} - -// Example SwiftUI View -struct ConfigDisplayView: View { - @StateObject private var configManager = ChurchConfigManager() - - var body: some View { - VStack(alignment: .leading, spacing: 8) { - Text(configManager.churchName) - .font(.title) - .foregroundColor(Color(hex: configManager.brandColor)) - - Text(configManager.aboutText) - .font(.body) - - Text("Contact: \(configManager.contactPhone)") - Text("Email: \(configManager.contactEmail)") - Text("Address: \(configManager.churchAddress)") - - if !configManager.donationUrl.isEmpty { - Link("Donate", destination: URL(string: configManager.donationUrl)!) - .foregroundColor(Color(hex: configManager.brandColor)) - } - } - .padding() - .onAppear { - configManager.loadConfig() - } - } -} - -extension Color { - init(hex: String) { - let hex = hex.trimmingCharacters(in: CharacterSet.alphanumerics.inverted) - var int: UInt64 = 0 - Scanner(string: hex).scanHexInt64(&int) - let a, r, g, b: UInt64 - switch hex.count { - case 3: // RGB (12-bit) - (a, r, g, b) = (255, (int >> 8) * 17, (int >> 4 & 0xF) * 17, (int & 0xF) * 17) - case 6: // RGB (24-bit) - (a, r, g, b) = (255, int >> 16, int >> 8 & 0xFF, int & 0xFF) - case 8: // ARGB (32-bit) - (a, r, g, b) = (int >> 24, int >> 16 & 0xFF, int >> 8 & 0xFF, int & 0xFF) - default: - (a, r, g, b) = (1, 1, 1, 0) - } - - self.init( - .sRGB, - red: Double(r) / 255, - green: Double(g) / 255, - blue: Double(b) / 255, - opacity: Double(a) / 255 - ) - } -} - -/* -Benefits of this approach: - -1. โœ… RTSDA Compliant - ALL business logic in Rust -2. โœ… No JSON parsing in Swift - Rust handles it all -3. โœ… Proper error handling with fallbacks in Rust -4. โœ… Consistent behavior across iOS and Android -5. โœ… Easy to test - just call Rust functions -6. โœ… No model synchronization issues -7. โœ… Automatic fallback values if config fails to load -8. โœ… Cleaner Swift code - just UI logic - -Functions available: -- getChurchName() -> String -- getContactPhone() -> String -- getContactEmail() -> String -- getBrandColor() -> String -- getAboutText() -> String -- getDonationUrl() -> String -- getChurchAddress() -> String -- getCoordinates() -> [Double] // [latitude, longitude] -- getWebsiteUrl() -> String -- getFacebookUrl() -> String -- getYoutubeUrl() -> String -- getInstagramUrl() -> String -- getMissionStatement() -> String -*/ \ No newline at end of file diff --git a/test_config_functions.rs b/test_config_functions.rs deleted file mode 100644 index b4786ae..0000000 --- a/test_config_functions.rs +++ /dev/null @@ -1,39 +0,0 @@ -// Test script for new config functions -use church_core::uniffi_wrapper::{ - get_church_name, - get_contact_phone, - get_contact_email, - get_brand_color, - get_about_text, - get_donation_url, - get_church_address, - get_coordinates, - get_website_url, - get_facebook_url, - get_youtube_url, - get_instagram_url, - get_mission_statement, -}; - -fn main() { - println!("๐Ÿ” Testing church-core config functions...\n"); - - println!("Church Name: {}", get_church_name()); - println!("Contact Phone: {}", get_contact_phone()); - println!("Contact Email: {}", get_contact_email()); - println!("Brand Color: {}", get_brand_color()); - println!("About Text: {}", get_about_text()); - println!("Donation URL: {}", get_donation_url()); - println!("Church Address: {}", get_church_address()); - - let coords = get_coordinates(); - println!("Coordinates: [{}, {}]", coords[0], coords[1]); - - println!("Website URL: {}", get_website_url()); - println!("Facebook URL: {}", get_facebook_url()); - println!("YouTube URL: {}", get_youtube_url()); - println!("Instagram URL: {}", get_instagram_url()); - println!("Mission Statement: {}", get_mission_statement()); - - println!("\nโœ… All config functions working properly with fallback values!"); -} \ No newline at end of file diff --git a/test_sermon_json.rs b/test_sermon_json.rs deleted file mode 100644 index 4d4dfd6..0000000 --- a/test_sermon_json.rs +++ /dev/null @@ -1,31 +0,0 @@ -use church_core::{ChurchApiClient, ChurchCoreConfig}; - -#[tokio::main] -async fn main() { - let config = ChurchCoreConfig::new(); - - match ChurchApiClient::new(config) { - Ok(client) => { - match client.get_recent_sermons(Some(5)).await { - Ok(sermons) => { - let client_sermons: Vec = sermons - .into_iter() - .map(church_core::ClientSermon::from) - .collect(); - - println!("๐ŸŽฌ Raw JSON output:"); - match serde_json::to_string_pretty(&client_sermons) { - Ok(json) => println!("{}", json), - Err(e) => println!("โŒ JSON serialization error: {}", e), - } - }, - Err(e) => { - println!("โŒ Failed to get sermons: {}", e); - } - } - } - Err(e) => { - println!("โŒ Failed to create client: {}", e); - } - } -} \ No newline at end of file