Add macOS app bundle packaging, native launcher, and MACOS_APP_PACKAGING guide
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
#!/bin/bash
|
||||
# build_app.sh - Build standalone macOS VoiceAgent.app bundle
|
||||
set -euo pipefail
|
||||
|
||||
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
cd "$HERE"
|
||||
|
||||
echo "=== 1. Building Swift Helper & Launcher Binaries ==="
|
||||
bash swift/build.sh
|
||||
|
||||
APP_NAME="VoiceAgent"
|
||||
DIST_DIR="$HERE/dist"
|
||||
APP_BUNDLE="$DIST_DIR/$APP_NAME.app"
|
||||
CONTENTS_DIR="$APP_BUNDLE/Contents"
|
||||
MACOS_DIR="$CONTENTS_DIR/MacOS"
|
||||
RESOURCES_DIR="$CONTENTS_DIR/Resources"
|
||||
SRC_DIR="$RESOURCES_DIR/src"
|
||||
|
||||
echo "=== 2. Creating macOS App Bundle Structure ==="
|
||||
rm -rf "$APP_BUNDLE"
|
||||
mkdir -p "$MACOS_DIR"
|
||||
mkdir -p "$RESOURCES_DIR/swift"
|
||||
mkdir -p "$SRC_DIR"
|
||||
|
||||
echo "=== 3. Compiling Native App Bundle Launcher ==="
|
||||
swiftc -O -parse-as-library "$HERE/swift/VoiceAgentLauncher.swift" -o "$MACOS_DIR/VoiceAgent"
|
||||
chmod +x "$MACOS_DIR/VoiceAgent"
|
||||
|
||||
echo "=== 4. Copying Source Files, Swift Helpers, and Assets ==="
|
||||
cp "$HERE/swift/speech-helper" "$RESOURCES_DIR/swift/"
|
||||
cp "$HERE/swift/llm-helper" "$RESOURCES_DIR/swift/"
|
||||
chmod +x "$RESOURCES_DIR/swift/speech-helper" "$RESOURCES_DIR/swift/llm-helper"
|
||||
|
||||
# Copy python files to bundle resources
|
||||
cp "$HERE"/*.py "$SRC_DIR/" 2>/dev/null || true
|
||||
if [ -f "$HERE/vocabulary.example.txt" ]; then
|
||||
cp "$HERE/vocabulary.example.txt" "$RESOURCES_DIR/"
|
||||
fi
|
||||
if [ -f "$HERE/corrections.example.txt" ]; then
|
||||
cp "$HERE/corrections.example.txt" "$RESOURCES_DIR/"
|
||||
fi
|
||||
|
||||
echo "=== 5. Generating Info.plist with Entitlements ==="
|
||||
cat << 'EOF' > "$CONTENTS_DIR/Info.plist"
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>VoiceAgent</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.voiceagent.mac</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>VoiceAgent</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>VoiceAgent</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.0.0</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>14.0</string>
|
||||
<key>NSMicrophoneUsageDescription</key>
|
||||
<string>VoiceAgent requires access to your microphone to listen to your voice commands.</string>
|
||||
<key>NSSpeechRecognitionUsageDescription</key>
|
||||
<string>VoiceAgent uses on-device speech recognition to process your spoken input.</string>
|
||||
<key>NSHighResolutionCapable</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
EOF
|
||||
|
||||
echo "=== 6. Code-signing App Bundle ==="
|
||||
codesign -s - --deep --force "$APP_BUNDLE"
|
||||
|
||||
echo "=== 7. Installing to /Applications ==="
|
||||
rm -rf /Applications/VoiceAgent.app
|
||||
cp -R "$APP_BUNDLE" /Applications/
|
||||
codesign -s - --deep --force /Applications/VoiceAgent.app
|
||||
|
||||
echo "=========================================================="
|
||||
echo "Successfully built and installed VoiceAgent.app to:"
|
||||
echo "1. /Applications/VoiceAgent.app"
|
||||
echo "2. $APP_BUNDLE"
|
||||
echo "=========================================================="
|
||||
Reference in New Issue
Block a user