Add macOS app bundle packaging, native launcher, and MACOS_APP_PACKAGING guide

This commit is contained in:
Adolfo Reyna
2026-08-08 17:37:52 -04:00
parent 757261ebfd
commit 6e8a578e86
8 changed files with 431 additions and 3 deletions
+47
View File
@@ -0,0 +1,47 @@
import Foundation
@main
struct VoiceAgentLauncher {
static func main() {
let fileManager = FileManager.default
let projDir = "/Users/adolforeyna/Projects/VoiceAgent1"
let bundleResPath = Bundle.main.resourcePath ?? ""
let bundledSrcPath = "\(bundleResPath)/src"
let workDir = fileManager.fileExists(atPath: projDir) ? projDir : bundledSrcPath
let pythonBin = "\(projDir)/.venv/bin/python"
let fallbackPython = "/usr/bin/python3"
let targetPython = fileManager.fileExists(atPath: pythonBin) ? pythonBin : fallbackPython
let targetScript = "\(workDir)/app_main.py"
setenv("SSL_CERT_FILE", "/etc/ssl/cert.pem", 1)
setenv("REQUESTS_CA_BUNDLE", "/etc/ssl/cert.pem", 1)
let logDir = fileManager.homeDirectoryForCurrentUser.appendingPathComponent("Library/Logs/VoiceAgent")
try? fileManager.createDirectory(at: logDir, withIntermediateDirectories: true)
let logFile = logDir.appendingPathComponent("voiceagent.log")
if !fileManager.fileExists(atPath: logFile.path) {
fileManager.createFile(atPath: logFile.path, contents: nil)
}
let process = Process()
process.executableURL = URL(fileURLWithPath: targetPython)
process.arguments = [targetScript]
process.currentDirectoryURL = URL(fileURLWithPath: workDir)
if let logHandle = try? FileHandle(forWritingTo: logFile) {
logHandle.seekToEndOfFile()
process.standardOutput = logHandle
process.standardError = logHandle
}
do {
try process.run()
process.waitUntilExit()
} catch {
print("Failed to run VoiceAgent: \(error)")
}
}
}