#!/bin/bash set -e echo "Building uskey.app..." APP_NAME="uskey" VERSION="${VERSION:-1.0.0}" BUILD_DIR=".build/release" APP_DIR="$BUILD_DIR/$APP_NAME.app" CONTENTS_DIR="$APP_DIR/Contents" MACOS_DIR="$CONTENTS_DIR/MacOS" RESOURCES_DIR="$CONTENTS_DIR/Resources" ICON_FILE="static/uskey.icns" echo "Step 1: Building release binary..." swift build -c release echo "Step 2: Creating app icon (if needed)..." if [ ! -f "$ICON_FILE" ]; then echo " Icon not found, creating from PNG..." ./create-icon.sh fi echo "Step 3: Creating app bundle structure..." rm -rf "$APP_DIR" mkdir -p "$MACOS_DIR" mkdir -p "$RESOURCES_DIR" echo "Step 4: Copying binary..." cp "$BUILD_DIR/$APP_NAME" "$MACOS_DIR/$APP_NAME" echo "Step 5: Copying icon..." if [ -f "$ICON_FILE" ]; then cp "$ICON_FILE" "$RESOURCES_DIR/$APP_NAME.icns" echo " Icon copied successfully" else echo " Warning: Icon file not found, skipping..." fi echo "Step 6: Creating Info.plist..." cat > "$CONTENTS_DIR/Info.plist" << EOF CFBundleDevelopmentRegion en CFBundleExecutable $APP_NAME CFBundleIconFile $APP_NAME CFBundleIdentifier com.uskey.app CFBundleInfoDictionaryVersion 6.0 CFBundleName $APP_NAME CFBundlePackageType APPL CFBundleShortVersionString $VERSION CFBundleVersion 1 LSMinimumSystemVersion 13.0 LSUIElement NSHighResolutionCapable NSHumanReadableCopyright Copyright © 2025. All rights reserved. EOF echo "Step 7: Setting permissions..." chmod +x "$MACOS_DIR/$APP_NAME" echo "" echo "✅ App bundle created at: $APP_DIR" echo "" echo "To create DMG, run: ./build-dmg.sh"