#!/bin/bash # Builds Konverter.app. # # ./build-app.sh # version from git tag, else 0.1.0 # ./build-app.sh 1.2.0 # explicit version # # Signs with the first Developer ID Application identity in the keychain when # one exists (needed for notarization), otherwise ad-hoc signs so the bundle # still runs locally. set -euo pipefail cd "$(dirname "$0")" if [ "${1:-}" != "" ]; then VERSION="$1" else VERSION=$(git describe --tags --abbrev=0 2>/dev/null | sed 's/^v//' || true) VERSION="${VERSION:-0.1.0}" fi swift build -c release BIN=".build/release/Konverter" APP="Konverter.app" if [ ! -x "$BIN" ]; then echo "build-app.sh: $BIN not found after swift build." >&2 exit 1 fi IDENT="" if command -v security >/dev/null 2>&1; then IDENT=$(security find-identity -v -p codesigning 2>/dev/null \ | awk '/Developer ID Application:/ { print $2; exit }') fi rm -rf "$APP" mkdir -p "$APP/Contents/MacOS" "$APP/Contents/Resources" cp "$BIN" "$APP/Contents/MacOS/Konverter" printf 'APPL????' > "$APP/Contents/PkgInfo" cat > "$APP/Contents/Info.plist" < CFBundleDevelopmentRegion en CFBundleExecutable Konverter CFBundleIconFile Icon CFBundleIdentifier dev.tzgyn.konverter CFBundleInfoDictionaryVersion 6.0 CFBundleName Konverter CFBundleDisplayName Konverter CFBundlePackageType APPL CFBundleShortVersionString ${VERSION} CFBundleVersion ${VERSION} LSMinimumSystemVersion 13.0 LSUIElement LSApplicationCategoryType public.app-category.utilities NSHighResolutionCapable NSPrincipalClass NSApplication NSHumanReadableCopyright Copyright © 2026 Teh Zi Gyn. All rights reserved. NSServices NSMenuItem default Convert with Konverter… NSMessage convertFiles NSPortName Konverter NSSendFileTypes public.item NSRequiredContext PLIST chmod +x scripts/make-icon.sh ./scripts/make-icon.sh if [ -n "$IDENT" ]; then security unlock-keychain "$HOME/Library/Keychains/login.keychain-db" 2>/dev/null || true codesign --force --options runtime --timestamp --sign "$IDENT" "$APP" echo "Built $APP $VERSION (signed with Developer ID '$IDENT')" else codesign --force --sign - "$APP" echo "Built $APP $VERSION (ad-hoc signed; not distributable)" fi