Skip to content

Let an AI model use a real iPhone with a $7 ESP32: AirPlay eyes, USB HID hands, any OpenAI-compatible vision model. No Mac, no developer account, no jailbreak.

Fix launch crash when MetricKit delivers a diagnostic (#16)

Eliot Andres6dec6a60ecdb
diff --git a/ios/IPhoneAgent/App/AppModel.swift b/ios/IPhoneAgent/App/AppModel.swift
index c4a26e6..7aa8a8b 100644
--- a/ios/IPhoneAgent/App/AppModel.swift
+++ b/ios/IPhoneAgent/App/AppModel.swift
@@ -92,7 +92,9 @@ import UIKit
pointer.screenAspect = { DeviceScreen.aspect }
pointer.locate = { [weak self] jpeg in await self?.locatePointer(jpeg) }
DebugLog.relay = { [weak self] line in
- MainActor.assumeIsolated { if !MockMode.on { self?.board.commands.relayLog(line) } }
+ // DebugLog.write runs on any thread (MetricKit delivers crash reports on a background queue).
+ let relay = { MainActor.assumeIsolated { if !MockMode.on { self?.board.commands.relayLog(line) } } }
+ Thread.isMainThread ? relay() : DispatchQueue.main.async(execute: relay)
}
board.commands.onAppCommand = { [weak self] line in self?.handleAppCommand(line) }
DebugLog.write("app launched \(Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") ?? "")"