#!/usr/bin/env bash # Build macOS .app bundle — run ON A MAC from project root: # chmod +x build/macos/build.sh # ./build/macos/build.sh set -euo pipefail ROOT="$(cd "$(dirname "$0")/../.." && pwd)" cd "$ROOT" echo "=== Scribd PDF Downloader — macOS build ===" if [[ "$(uname)" != "Darwin" ]]; then echo "Error: macOS builds must run on a Mac (MacBook Pro, etc.)." exit 1 fi if [[ ! -d .venv ]]; then echo "Creating virtual environment..." python3 -m venv .venv fi # shellcheck disable=SC1091 source .venv/bin/activate pip install -r requirements-build.txt -q echo "Installing Chromium into package (for bundling)..." export PLAYWRIGHT_BROWSERS_PATH=0 playwright install chromium echo "Running PyInstaller..." pyinstaller --noconfirm --clean build/scribd_gui.spec APP="dist/Scribd PDF Downloader.app" if [[ ! -d "$APP" ]]; then echo "Error: $APP not found." exit 1 fi cp -f config.ini "$APP/Contents/MacOS/" 2>/dev/null || cp -f config.ini "$APP/Contents/Resources/" 2>/dev/null || true ZIP="dist/Scribd-PDF-Downloader-macOS.zip" rm -f "$ZIP" ditto -c -k --sequesterRsrc --keepParent "$APP" "$ZIP" echo "" echo "Build complete!" echo " App: $APP" echo " Zip: $ZIP" echo "" echo "First launch: right-click → Open (Gatekeeper) if macOS blocks the app." echo "Optional signing: codesign --force --deep --sign - \"$APP\""