#!/bin/bash # TimeSafari iOS Asset Generation Script # Manually generates iOS assets using ImageMagick when capacitor-assets fails # Author: Matthew Raymer set -e SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PROJECT_ROOT="$(dirname "$SCRIPT_DIR")" IOS_ASSETS_DIR="$PROJECT_ROOT/ios/App/App/Assets.xcassets" RESOURCES_DIR="$PROJECT_ROOT/resources/ios" echo "=== TimeSafari iOS Asset Generation ===" echo "[$(date '+%Y-%m-%d %H:%M:%S')] [INFO] Generating iOS assets manually" # Check if ImageMagick is available if ! command -v convert &> /dev/null; then echo "[ERROR] ImageMagick 'convert' command not found. Please install ImageMagick." exit 1 fi # Check if source files exist if [ ! -f "$RESOURCES_DIR/icon/icon.png" ]; then echo "[ERROR] Source icon not found: $RESOURCES_DIR/icon/icon.png" exit 1 fi if [ ! -f "$RESOURCES_DIR/splash/splash.png" ]; then echo "[ERROR] Source splash not found: $RESOURCES_DIR/splash/splash.png" exit 1 fi if [ ! -f "$RESOURCES_DIR/splash/splash_dark.png" ]; then echo "[ERROR] Source dark splash not found: $RESOURCES_DIR/splash/splash_dark.png" exit 1 fi echo "[INFO] Generating iOS app icons..." # Generate app icons for different sizes # iPhone icons convert "$RESOURCES_DIR/icon/icon.png" -resize 40x40 "$IOS_ASSETS_DIR/AppIcon.appiconset/AppIcon-20@2x.png" convert "$RESOURCES_DIR/icon/icon.png" -resize 60x60 "$IOS_ASSETS_DIR/AppIcon.appiconset/AppIcon-20@3x.png" convert "$RESOURCES_DIR/icon/icon.png" -resize 58x58 "$IOS_ASSETS_DIR/AppIcon.appiconset/AppIcon-29@2x.png" convert "$RESOURCES_DIR/icon/icon.png" -resize 87x87 "$IOS_ASSETS_DIR/AppIcon.appiconset/AppIcon-29@3x.png" convert "$RESOURCES_DIR/icon/icon.png" -resize 80x80 "$IOS_ASSETS_DIR/AppIcon.appiconset/AppIcon-40@2x.png" convert "$RESOURCES_DIR/icon/icon.png" -resize 120x120 "$IOS_ASSETS_DIR/AppIcon.appiconset/AppIcon-40@3x.png" convert "$RESOURCES_DIR/icon/icon.png" -resize 120x120 "$IOS_ASSETS_DIR/AppIcon.appiconset/AppIcon-60@2x.png" convert "$RESOURCES_DIR/icon/icon.png" -resize 180x180 "$IOS_ASSETS_DIR/AppIcon.appiconset/AppIcon-60@3x.png" # iPad icons convert "$RESOURCES_DIR/icon/icon.png" -resize 20x20 "$IOS_ASSETS_DIR/AppIcon.appiconset/AppIcon-20@1x.png" convert "$RESOURCES_DIR/icon/icon.png" -resize 40x40 "$IOS_ASSETS_DIR/AppIcon.appiconset/AppIcon-20@2x.png" convert "$RESOURCES_DIR/icon/icon.png" -resize 29x29 "$IOS_ASSETS_DIR/AppIcon.appiconset/AppIcon-29@1x.png" convert "$RESOURCES_DIR/icon/icon.png" -resize 58x58 "$IOS_ASSETS_DIR/AppIcon.appiconset/AppIcon-29@2x.png" convert "$RESOURCES_DIR/icon/icon.png" -resize 40x40 "$IOS_ASSETS_DIR/AppIcon.appiconset/AppIcon-40@1x.png" convert "$RESOURCES_DIR/icon/icon.png" -resize 80x80 "$IOS_ASSETS_DIR/AppIcon.appiconset/AppIcon-40@2x.png" convert "$RESOURCES_DIR/icon/icon.png" -resize 152x152 "$IOS_ASSETS_DIR/AppIcon.appiconset/AppIcon-76@2x.png" convert "$RESOURCES_DIR/icon/icon.png" -resize 167x167 "$IOS_ASSETS_DIR/AppIcon.appiconset/AppIcon-83.5@2x.png" # App Store icon convert "$RESOURCES_DIR/icon/icon.png" -resize 1024x1024 "$IOS_ASSETS_DIR/AppIcon.appiconset/AppIcon-1024@1x.png" echo "[INFO] Generating iOS splash screens..." # Generate splash screens for different scales convert "$RESOURCES_DIR/splash/splash.png" -resize 320x480 "$IOS_ASSETS_DIR/Splash.imageset/splash@1x.png" convert "$RESOURCES_DIR/splash/splash.png" -resize 640x960 "$IOS_ASSETS_DIR/Splash.imageset/splash@2x.png" convert "$RESOURCES_DIR/splash/splash.png" -resize 960x1440 "$IOS_ASSETS_DIR/Splash.imageset/splash@3x.png" # Generate dark splash screens convert "$RESOURCES_DIR/splash/splash_dark.png" -resize 320x480 "$IOS_ASSETS_DIR/SplashDark.imageset/splash@1x.png" convert "$RESOURCES_DIR/splash/splash_dark.png" -resize 640x960 "$IOS_ASSETS_DIR/SplashDark.imageset/splash@2x.png" convert "$RESOURCES_DIR/splash/splash_dark.png" -resize 960x1440 "$IOS_ASSETS_DIR/SplashDark.imageset/splash@3x.png" echo "[INFO] Updating Contents.json files to reference generated images..." # Update AppIcon Contents.json to reference the generated files cat > "$IOS_ASSETS_DIR/AppIcon.appiconset/Contents.json" << 'EOF' { "images" : [ { "filename" : "AppIcon-20@2x.png", "idiom" : "iphone", "scale" : "2x", "size" : "20x20" }, { "filename" : "AppIcon-20@3x.png", "idiom" : "iphone", "scale" : "3x", "size" : "20x20" }, { "filename" : "AppIcon-29@2x.png", "idiom" : "iphone", "scale" : "2x", "size" : "29x29" }, { "filename" : "AppIcon-29@3x.png", "idiom" : "iphone", "scale" : "3x", "size" : "29x29" }, { "filename" : "AppIcon-40@2x.png", "idiom" : "iphone", "scale" : "2x", "size" : "40x40" }, { "filename" : "AppIcon-40@3x.png", "idiom" : "iphone", "scale" : "3x", "size" : "40x40" }, { "filename" : "AppIcon-60@2x.png", "idiom" : "iphone", "scale" : "2x", "size" : "60x60" }, { "filename" : "AppIcon-60@3x.png", "idiom" : "iphone", "scale" : "3x", "size" : "60x60" }, { "filename" : "AppIcon-20@1x.png", "idiom" : "ipad", "scale" : "1x", "size" : "20x20" }, { "filename" : "AppIcon-20@2x.png", "idiom" : "ipad", "scale" : "2x", "size" : "20x20" }, { "filename" : "AppIcon-29@1x.png", "idiom" : "ipad", "scale" : "1x", "size" : "29x29" }, { "filename" : "AppIcon-29@2x.png", "idiom" : "ipad", "scale" : "2x", "size" : "29x29" }, { "filename" : "AppIcon-40@1x.png", "idiom" : "ipad", "scale" : "1x", "size" : "40x40" }, { "filename" : "AppIcon-40@2x.png", "idiom" : "ipad", "scale" : "2x", "size" : "40x40" }, { "filename" : "AppIcon-76@2x.png", "idiom" : "ipad", "scale" : "2x", "size" : "76x76" }, { "filename" : "AppIcon-83.5@2x.png", "idiom" : "ipad", "scale" : "2x", "size" : "83.5x83.5" }, { "filename" : "AppIcon-1024@1x.png", "idiom" : "ios-marketing", "scale" : "1x", "size" : "1024x1024" } ], "info" : { "author" : "xcode", "version" : 1 } } EOF # Update Splash Contents.json to reference the generated files cat > "$IOS_ASSETS_DIR/Splash.imageset/Contents.json" << 'EOF' { "images" : [ { "filename" : "splash@1x.png", "idiom" : "universal", "scale" : "1x" }, { "filename" : "splash@2x.png", "idiom" : "universal", "scale" : "2x" }, { "filename" : "splash@3x.png", "idiom" : "universal", "scale" : "3x" } ], "info" : { "author" : "xcode", "version" : 1 } } EOF # Update SplashDark Contents.json to reference the generated files cat > "$IOS_ASSETS_DIR/SplashDark.imageset/Contents.json" << 'EOF' { "images" : [ { "filename" : "splash@1x.png", "idiom" : "universal", "scale" : "1x" }, { "filename" : "splash@2x.png", "idiom" : "universal", "scale" : "2x" }, { "filename" : "splash@3x.png", "idiom" : "universal", "scale" : "3x" } ], "info" : { "author" : "xcode", "version" : 1 } } EOF echo "[SUCCESS] iOS assets generated successfully!" echo "[INFO] Generated files:" find "$IOS_ASSETS_DIR" -name "*.png" | sort echo "" echo "[NOTE] iOS builds require macOS with Xcode - cannot build on Linux" echo "[INFO] Assets are now ready for when you build on macOS"