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.
 
 
 
 
 
 

294 lines
7.1 KiB

#!/bin/bash
# TimeSafari iOS Resource Check Script
# Checks for missing iOS resources and automatically fixes common issues
# 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 Resource Check ==="
echo "[$(date '+%Y-%m-%d %H:%M:%S')] [INFO] Checking iOS resources"
# Function to check if a file exists
check_file() {
local file="$1"
local description="$2"
if [ -f "$file" ]; then
echo "[✓] $description: $file"
return 0
else
echo "[✗] $description: $file (MISSING)"
return 1
fi
}
# Function to check if a directory exists and has files
check_directory() {
local dir="$1"
local description="$2"
if [ -d "$dir" ] && [ "$(ls -A "$dir" 2>/dev/null)" ]; then
echo "[✓] $description: $dir"
return 0
else
echo "[✗] $description: $dir (MISSING OR EMPTY)"
return 1
fi
}
# Track issues
issues_found=0
fixes_applied=0
echo "[INFO] Checking iOS asset catalog structure..."
# Check if Assets.xcassets directory exists
if ! check_directory "$IOS_ASSETS_DIR" "iOS Assets.xcassets directory"; then
echo "[FIX] Creating iOS Assets.xcassets directory..."
mkdir -p "$IOS_ASSETS_DIR"
fixes_applied=$((fixes_applied + 1))
fi
# Check main Contents.json
if ! check_file "$IOS_ASSETS_DIR/Contents.json" "Main Assets.xcassets Contents.json"; then
echo "[FIX] Creating main Assets.xcassets Contents.json..."
cat > "$IOS_ASSETS_DIR/Contents.json" << 'EOF'
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
EOF
fixes_applied=$((fixes_applied + 1))
fi
echo "[INFO] Checking App Icon resources..."
# Check App Icon directory
if ! check_directory "$IOS_ASSETS_DIR/AppIcon.appiconset" "App Icon directory"; then
echo "[FIX] Creating App Icon directory..."
mkdir -p "$IOS_ASSETS_DIR/AppIcon.appiconset"
fixes_applied=$((fixes_applied + 1))
fi
# Check App Icon Contents.json
if ! check_file "$IOS_ASSETS_DIR/AppIcon.appiconset/Contents.json" "App Icon Contents.json"; then
echo "[FIX] Creating App Icon Contents.json..."
cat > "$IOS_ASSETS_DIR/AppIcon.appiconset/Contents.json" << 'EOF'
{
"images" : [
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "40x40"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "40x40"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "60x60"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "60x60"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "20x20"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "20x20"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "29x29"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "29x29"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "40x40"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "40x40"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "76x76"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "83.5x83.5"
},
{
"idiom" : "ios-marketing",
"scale" : "1x",
"size" : "1024x1024"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
EOF
fixes_applied=$((fixes_applied + 1))
fi
echo "[INFO] Checking Splash Screen resources..."
# Check Splash directory
if ! check_directory "$IOS_ASSETS_DIR/Splash.imageset" "Splash screen directory"; then
echo "[FIX] Creating Splash screen directory..."
mkdir -p "$IOS_ASSETS_DIR/Splash.imageset"
fixes_applied=$((fixes_applied + 1))
fi
# Check Splash Contents.json
if ! check_file "$IOS_ASSETS_DIR/Splash.imageset/Contents.json" "Splash screen Contents.json"; then
echo "[FIX] Creating Splash screen Contents.json..."
cat > "$IOS_ASSETS_DIR/Splash.imageset/Contents.json" << 'EOF'
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
EOF
fixes_applied=$((fixes_applied + 1))
fi
# Check SplashDark directory
if ! check_directory "$IOS_ASSETS_DIR/SplashDark.imageset" "Dark splash screen directory"; then
echo "[FIX] Creating Dark splash screen directory..."
mkdir -p "$IOS_ASSETS_DIR/SplashDark.imageset"
fixes_applied=$((fixes_applied + 1))
fi
# Check SplashDark Contents.json
if ! check_file "$IOS_ASSETS_DIR/SplashDark.imageset/Contents.json" "Dark splash screen Contents.json"; then
echo "[FIX] Creating Dark splash screen Contents.json..."
cat > "$IOS_ASSETS_DIR/SplashDark.imageset/Contents.json" << 'EOF'
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
EOF
fixes_applied=$((fixes_applied + 1))
fi
echo "[INFO] Checking source resource files..."
# Check if source resources exist
if ! check_file "$RESOURCES_DIR/icon/icon.png" "iOS icon source"; then
issues_found=$((issues_found + 1))
fi
if ! check_file "$RESOURCES_DIR/splash/splash.png" "iOS splash source"; then
issues_found=$((issues_found + 1))
fi
if ! check_file "$RESOURCES_DIR/splash/splash_dark.png" "iOS dark splash source"; then
issues_found=$((issues_found + 1))
fi
echo "[INFO] Checking iOS platform status..."
# Check if iOS platform is properly initialized
if [ ! -d "$PROJECT_ROOT/ios" ]; then
echo "[ERROR] iOS platform directory not found"
issues_found=$((issues_found + 1))
elif [ ! -f "$PROJECT_ROOT/ios/App/App/Info.plist" ]; then
echo "[ERROR] Info.plist not found - platform may be corrupted"
issues_found=$((issues_found + 1))
else
echo "[✓] iOS platform appears to be properly initialized"
fi
# Summary
echo ""
echo "=== iOS Resource Check Summary ==="
if [ $issues_found -eq 0 ] && [ $fixes_applied -eq 0 ]; then
echo "[SUCCESS] All iOS resources are present and valid"
exit 0
elif [ $fixes_applied -gt 0 ]; then
echo "[SUCCESS] Fixed $fixes_applied resource issues automatically"
if [ $issues_found -gt 0 ]; then
echo "[WARNING] $issues_found issues remain that require manual attention"
echo "[NOTE] iOS builds require macOS with Xcode - cannot build on Linux"
exit 1
else
exit 0
fi
else
echo "[ERROR] Found $issues_found resource issues that require manual attention"
echo "[NOTE] iOS builds require macOS with Xcode - cannot build on Linux"
exit 1
fi