#!/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 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. For distribution, consider code signing:" echo " codesign --deep --force --verify --verbose --sign \"Developer ID Application: Your Name\" dist/HereIAm.app" echo "3. 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