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.
 
 
 
 
 
 

161 lines
4.2 KiB

#!/bin/bash
# Native iOS Development App Build and Deploy Script
# Builds and deploys the ios/App development app to iOS Simulator
# Similar to android/app - a simple Capacitor app for plugin development
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)"
# Check if we're in the project root
if [ ! -d "$PROJECT_ROOT/ios/App" ]; then
log_error "ios/App directory not found"
log_info "This script must be run from the project root directory"
log_info "Usage: cd /path/to/daily-notification-plugin && ./scripts/build-and-deploy-native-ios.sh"
exit 1
fi
# Check prerequisites
log_step "Checking prerequisites..."
if ! command -v xcodebuild &> /dev/null; then
log_error "xcodebuild not found. Install Xcode command line tools:"
log_info " xcode-select --install"
exit 1
fi
if ! command -v pod &> /dev/null; then
log_error "CocoaPods not found. Install with:"
log_info " gem install cocoapods"
exit 1
fi
# Get simulator device (default to iPhone 15 Pro)
SIMULATOR_DEVICE="${1:-iPhone 15 Pro}"
log_info "Using simulator: $SIMULATOR_DEVICE"
# Boot simulator
log_step "Booting simulator..."
if xcrun simctl list devices | grep -q "$SIMULATOR_DEVICE.*Booted"; then
log_info "Simulator already booted"
else
# Try to boot the device
if xcrun simctl boot "$SIMULATOR_DEVICE" 2>/dev/null; then
log_info "✓ Simulator booted"
else
log_warn "Could not boot simulator automatically"
log_info "Opening Simulator app... (you may need to select device manually)"
open -a Simulator
sleep 5
fi
fi
# Build plugin
log_step "Building plugin..."
cd "$PROJECT_ROOT"
if ! ./scripts/build-native.sh --platform ios; then
log_error "Plugin build failed"
exit 1
fi
# Install CocoaPods dependencies
log_step "Installing CocoaPods dependencies..."
cd "$PROJECT_ROOT/ios"
if [ ! -f "Podfile.lock" ] || [ "Podfile" -nt "Podfile.lock" ]; then
pod install
else
log_info "CocoaPods dependencies up to date"
fi
# Build iOS app
log_step "Building native iOS development app..."
cd "$PROJECT_ROOT/ios/App"
WORKSPACE="App.xcworkspace"
SCHEME="App"
CONFIG="Debug"
SDK="iphonesimulator"
if ! xcodebuild -workspace "$WORKSPACE" \
-scheme "$SCHEME" \
-configuration "$CONFIG" \
-sdk "$SDK" \
-destination "platform=iOS Simulator,name=$SIMULATOR_DEVICE" \
-derivedDataPath build/derivedData \
CODE_SIGN_IDENTITY="" \
CODE_SIGNING_REQUIRED=NO \
CODE_SIGNING_ALLOWED=NO \
clean build; then
log_error "iOS app build failed"
exit 1
fi
# Find built app
APP_PATH=$(find build/derivedData -name "*.app" -type d -path "*/Build/Products/*-iphonesimulator/*.app" | head -1)
if [ -z "$APP_PATH" ]; then
log_error "Could not find built app"
log_info "Searching in: build/derivedData"
find build/derivedData -name "*.app" -type d 2>/dev/null | head -5
exit 1
fi
log_info "Found app: $APP_PATH"
# Install app on simulator
log_step "Installing app on simulator..."
if xcrun simctl install booted "$APP_PATH"; then
log_info "✓ App installed"
else
log_error "Failed to install app"
exit 1
fi
# Get bundle identifier
BUNDLE_ID=$(plutil -extract CFBundleIdentifier raw App/Info.plist 2>/dev/null || echo "com.timesafari.dailynotification")
log_info "Bundle ID: $BUNDLE_ID"
# Launch app
log_step "Launching app..."
if xcrun simctl launch booted "$BUNDLE_ID"; then
log_info "✓ App launched"
else
log_warn "App may already be running"
fi
log_info ""
log_info "✅ Build and deploy complete!"
log_info ""
log_info "To view logs:"
log_info " xcrun simctl spawn booted log stream"
log_info ""
log_info "To uninstall app:"
log_info " xcrun simctl uninstall booted $BUNDLE_ID"
log_info ""
log_info "Note: This is the native iOS development app (ios/App)"
log_info "For the Vue 3 test app, use: test-apps/daily-notification-test/scripts/build-and-deploy-ios.sh"