You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

245 lines
7.6 KiB

#!/bin/bash
# Complete Build Script - Build Everything from Console
# Builds plugin, iOS app, Android app, and all dependencies
#
# Usage:
# ./scripts/build-all.sh [platform]
# Platform options: ios, android, all (default: all)
#
# @author Matthew Raymer
# @version 1.0.0
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
log_info() {
echo -e "${GREEN}[INFO]${NC} $1"
}
log_warn() {
echo -e "${YELLOW}[WARN]${NC} $1"
}
log_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
log_step() {
echo -e "${BLUE}[STEP]${NC} $1"
}
# Get script directory
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
# Parse arguments
PLATFORM="${1:-all}"
# Validate platform
if [[ ! "$PLATFORM" =~ ^(ios|android|all)$ ]]; then
log_error "Invalid platform: $PLATFORM"
log_info "Usage: $0 [ios|android|all]"
exit 1
fi
cd "$PROJECT_ROOT"
log_info "=========================================="
log_info "Complete Build Script"
log_info "Platform: $PLATFORM"
log_info "=========================================="
log_info ""
# Build TypeScript and plugin code
log_step "Building plugin (TypeScript + Native)..."
if ! ./scripts/build-native.sh --platform "$PLATFORM" 2>&1 | tee /tmp/build-native-output.log; then
log_error "Plugin build failed"
log_info ""
log_info "Full build output saved to: /tmp/build-native-output.log"
log_info "View errors: grep -E '(error:|ERROR|FAILED)' /tmp/build-native-output.log"
log_info ""
log_info "Checking for xcodebuild logs..."
if [ -f "/tmp/xcodebuild_device.log" ]; then
log_info "Device build errors:"
grep -E "(error:|warning:)" /tmp/xcodebuild_device.log | head -30
fi
if [ -f "/tmp/xcodebuild_simulator.log" ]; then
log_info "Simulator build errors:"
grep -E "(error:|warning:)" /tmp/xcodebuild_simulator.log | head -30
fi
exit 1
fi
# Build Android
if [[ "$PLATFORM" == "android" || "$PLATFORM" == "all" ]]; then
log_step "Building Android app..."
cd "$PROJECT_ROOT/android"
if [ ! -f "gradlew" ]; then
log_error "Gradle wrapper not found. Run: cd android && ./gradlew wrapper"
exit 1
fi
# Build Android app
if ! ./gradlew :app:assembleDebug; then
log_error "Android build failed"
exit 1
fi
APK_PATH="app/build/outputs/apk/debug/app-debug.apk"
if [ -f "$APK_PATH" ]; then
log_info "✓ Android APK: $APK_PATH"
else
log_error "Android APK not found at $APK_PATH"
exit 1
fi
log_info ""
fi
# Build iOS
if [[ "$PLATFORM" == "ios" || "$PLATFORM" == "all" ]]; then
log_step "Building iOS app..."
cd "$PROJECT_ROOT/ios"
# Check if CocoaPods is installed
if ! command -v pod &> /dev/null; then
log_error "CocoaPods not found. Install with: gem install cocoapods"
exit 1
fi
# Install CocoaPods dependencies
log_step "Installing CocoaPods dependencies..."
if [ ! -f "Podfile.lock" ] || [ "Podfile" -nt "Podfile.lock" ]; then
pod install
else
log_info "CocoaPods dependencies up to date"
fi
# Check if App workspace exists
if [ ! -d "App/App.xcworkspace" ] && [ ! -d "App/App.xcodeproj" ]; then
log_warn "iOS app Xcode project not found"
log_info "The iOS app may need to be initialized with Capacitor"
log_info "Try: cd ios && npx cap sync ios"
log_info ""
log_info "Attempting to build plugin framework only..."
# Build plugin framework only
cd "$PROJECT_ROOT/ios"
if [ -d "DailyNotificationPlugin.xcworkspace" ]; then
WORKSPACE="DailyNotificationPlugin.xcworkspace"
SCHEME="DailyNotificationPlugin"
CONFIG="Debug"
log_step "Building plugin framework for simulator..."
xcodebuild build \
-workspace "$WORKSPACE" \
-scheme "$SCHEME" \
-configuration "$CONFIG" \
-sdk iphonesimulator \
-destination 'generic/platform=iOS Simulator' \
CODE_SIGN_IDENTITY="" \
CODE_SIGNING_REQUIRED=NO \
CODE_SIGNING_ALLOWED=NO || log_warn "Plugin framework build failed (may need Xcode project setup)"
else
log_error "Cannot find iOS workspace or project"
exit 1
fi
else
# Build iOS app
cd "$PROJECT_ROOT/ios/App"
# Determine workspace vs project
if [ -d "App.xcworkspace" ]; then
WORKSPACE="App.xcworkspace"
BUILD_CMD="xcodebuild -workspace"
elif [ -d "App.xcodeproj" ]; then
PROJECT="App.xcodeproj"
BUILD_CMD="xcodebuild -project"
else
log_error "Cannot find iOS workspace or project"
exit 1
fi
SCHEME="App"
CONFIG="Debug"
SDK="iphonesimulator"
log_step "Building iOS app for simulator..."
if [ -n "$WORKSPACE" ]; then
BUILD_OUTPUT=$(xcodebuild build \
-workspace "$WORKSPACE" \
-scheme "$SCHEME" \
-configuration "$CONFIG" \
-sdk "$SDK" \
-destination 'generic/platform=iOS Simulator' \
-derivedDataPath build/derivedData \
CODE_SIGN_IDENTITY="" \
CODE_SIGNING_REQUIRED=NO \
CODE_SIGNING_ALLOWED=NO \
2>&1)
else
BUILD_OUTPUT=$(xcodebuild build \
-project "$PROJECT" \
-scheme "$SCHEME" \
-configuration "$CONFIG" \
-sdk "$SDK" \
-destination 'generic/platform=iOS Simulator' \
-derivedDataPath build/derivedData \
CODE_SIGN_IDENTITY="" \
CODE_SIGNING_REQUIRED=NO \
CODE_SIGNING_ALLOWED=NO \
2>&1)
fi
if echo "$BUILD_OUTPUT" | grep -q "BUILD SUCCEEDED"; then
log_info "✓ iOS app build completed successfully"
# Find built app
APP_PATH=$(find build/derivedData -name "*.app" -type d -path "*/Build/Products/*-iphonesimulator/*.app" | head -1)
if [ -n "$APP_PATH" ]; then
log_info "✓ iOS app bundle: $APP_PATH"
fi
elif echo "$BUILD_OUTPUT" | grep -q "error:"; then
log_error "iOS app build failed"
echo "$BUILD_OUTPUT" | grep -E "(error:|warning:)" | head -20
exit 1
else
log_warn "iOS app build completed with warnings"
echo "$BUILD_OUTPUT" | grep -E "(warning:|error:)" | head -10
fi
fi
log_info ""
fi
log_info "=========================================="
log_info "✅ Build Complete!"
log_info "=========================================="
log_info ""
# Summary
if [[ "$PLATFORM" == "android" || "$PLATFORM" == "all" ]]; then
log_info "Android APK: android/app/build/outputs/apk/debug/app-debug.apk"
log_info "Install: adb install android/app/build/outputs/apk/debug/app-debug.apk"
fi
if [[ "$PLATFORM" == "ios" || "$PLATFORM" == "all" ]]; then
log_info "iOS App: ios/App/build/derivedData/Build/Products/Debug-iphonesimulator/App.app"
log_info "Install: xcrun simctl install booted <APP_PATH>"
fi
log_info ""
log_info "For deployment scripts, see:"
log_info " - scripts/build-and-deploy-native-ios.sh (iOS native app)"
log_info " - test-apps/daily-notification-test/scripts/build-and-deploy-ios.sh (Vue 3 test app)"