Files
HereIAm/build_app.sh
Jerico Thomas d93ce669b1 1.0.1
2025-08-01 12:29:34 -04:00

136 lines
4.4 KiB
Bash
Executable File

#!/bin/bash
# HereIAm Build Script
# This script builds the macOS .app bundle for distribution
set -e # Exit on any error
echo "🚀 Building HereIAm.app for macOS..."
echo "======================================="
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Get script directory
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
cd "$SCRIPT_DIR"
# Check if virtual environment exists and activate it
if [ -d ".venv" ]; then
echo -e "${BLUE}📦 Activating virtual environment...${NC}"
source .venv/bin/activate
else
echo -e "${YELLOW}⚠️ No virtual environment found. Using system Python.${NC}"
fi
# Check Python version
echo -e "${BLUE}🐍 Checking Python version...${NC}"
python_version=$(python3 --version 2>&1)
echo "Using: $python_version"
# Install/upgrade build dependencies
echo -e "${BLUE}📚 Installing build dependencies...${NC}"
pip install --upgrade pip
pip install pyinstaller
pip install -r requirements.txt
# Clean previous builds
echo -e "${BLUE}🧹 Cleaning previous builds...${NC}"
rm -rf build/
rm -rf dist/
rm -rf __pycache__/
find . -name "*.pyc" -delete
find . -name "__pycache__" -type d -exec rm -rf {} + 2>/dev/null || true
# Verify assets exist
echo -e "${BLUE}🎨 Verifying assets...${NC}"
if [ ! -f "assets/Enabled.icns" ]; then
echo -e "${RED}❌ Error: assets/Enabled.icns not found!${NC}"
exit 1
fi
if [ ! -f "assets/Disabled-Light.icns" ]; then
echo -e "${RED}❌ Error: assets/Disabled-Light.icns not found!${NC}"
exit 1
fi
if [ ! -f "assets/Disabled-Dark.icns" ]; then
echo -e "${RED}❌ Error: assets/Disabled-Dark.icns not found!${NC}"
exit 1
fi
echo -e "${GREEN}✅ All assets found${NC}"
# Build the application
echo -e "${BLUE}🔨 Building application with PyInstaller...${NC}"
pyinstaller --clean HereIAm.spec
# Check if build was successful
if [ -d "dist/HereIAm.app" ]; then
echo -e "${GREEN}✅ Build successful!${NC}"
# Get app size
app_size=$(du -sh "dist/HereIAm.app" | cut -f1)
echo -e "${GREEN}📦 App size: $app_size${NC}"
# Verify the app structure
echo -e "${BLUE}🔍 Verifying app structure...${NC}"
if [ -f "dist/HereIAm.app/Contents/MacOS/HereIAm" ]; then
echo -e "${GREEN}✅ Executable found${NC}"
else
echo -e "${RED}❌ Executable not found${NC}"
exit 1
fi
if [ -d "dist/HereIAm.app/Contents/Resources/assets" ]; then
echo -e "${GREEN}✅ Assets bundled${NC}"
else
echo -e "${RED}❌ Assets not found${NC}"
exit 1
fi
# Optional: Test if the app can be launched (basic check)
echo -e "${BLUE}🧪 Testing app launch (will quit immediately)...${NC}"
timeout 5s dist/HereIAm.app/Contents/MacOS/HereIAm || true
# Try to self-sign the app for better permissions
echo -e "${BLUE}🔐 Attempting to self-sign app for better permissions...${NC}"
if command -v codesign >/dev/null 2>&1; then
# Create a temporary signing identity if none exists
codesign --force --deep --sign - dist/HereIAm.app || {
echo -e "${YELLOW}⚠️ Code signing failed - app may have permission issues${NC}"
}
# Verify the signing
if codesign --verify --deep --strict --verbose=2 dist/HereIAm.app >/dev/null 2>&1; then
echo -e "${GREEN}✅ App successfully self-signed${NC}"
else
echo -e "${YELLOW}⚠️ App signing verification failed${NC}"
fi
else
echo -e "${YELLOW}⚠️ codesign not available - app may have permission issues${NC}"
fi
echo ""
echo -e "${GREEN}🎉 Build completed successfully!${NC}"
echo -e "${GREEN}📱 Your app is ready at: dist/HereIAm.app${NC}"
echo ""
echo -e "${YELLOW}📝 Next steps:${NC}"
echo "1. Test the app: open dist/HereIAm.app"
echo "2. Grant Accessibility permissions in System Preferences > Privacy & Security > Accessibility"
echo "3. If mouse movement still doesn't work, check Console.app for error messages"
echo "4. For distribution, consider proper code signing:"
echo " codesign --deep --force --verify --verbose --sign \"Developer ID Application: Your Name\" dist/HereIAm.app"
echo "5. Create a DMG for distribution:"
echo " ./create_dmg.sh"
echo ""
else
echo -e "${RED}❌ Build failed! Check the output above for errors.${NC}"
exit 1
fi