Fix iOS simulator watchdog crash in iCloud backup transport (Kotlin Multiplatform)
Session from pi-coding-sessions on Hugging Face by championswimmer · MIT · condensed by Coders Talk
Diagnose and fix an EXC_CRASH/8BADF00D watchdog crash occurring when running the app with iCloud enabled on the simulator, then verify by running the built app on the running simulator.
- +0Prompt · +0Solve the crash that happens when running the app with iCloud enabled on simulator; feel free to search the internet to debug.
- +0mAgent did · +0mRead module docs, searched codebase for ICloudBackupTransport, isAvailable, and BackupTransportRegistry, and inspected SettingsScreen to trace where the crash originates.
- +0mAgent did · +0mSearched the web for guidance on iOS ubiquity container/file existence checks blocking the main thread and causing 8BADF00D watchdog terminations, confirming the suspected root cause.
- +1mAgent did · +1mTagged context checkpoints, then edited ICloudBackupTransport.kt to move file system operations (fileExists, ensureBackupDirectoryExists) off the main thread using Dispatchers.IO via a new runFileSystemTask helper.
- +1mAgent did · +1mRan the Gradle iOS simulator framework link build to verify the fix compiles, checked git diff to confirm only the intended file changed, and summarized the root cause and fix.
- +2mPrompt · +2mRun it on the simulator for iPhone (that is already running).
- +2mFail · +2mMultiple xcodebuild invocations failed with scheme/target/destination errors while trying to build and target the already-booted iPhone simulator.
- +3mAgent did · +3mLocated the built TwoFac.app in DerivedData, installed and launched it via simctl on the booted iPhone 16 w Watch simulator, then verified the process was running via launchctl print.
- +5mOutcome · +5mFix implemented in ICloudBackupTransport.kt (moved file I/O off main thread); app installed and launched on booted iPhone 16 w Watch simulator (PID 76282), running state confirmed via launchctl.
Next time I'd point straight at the ICloudBackupTransport file since the crash log made the source pretty obvious, and let the agent confirm the main-thread-blocking theory with a quick web search before touching code. The web search confirming that NSFileManager and ubiquity container calls block the main thread is what actually justified the fix — everything else was just locating the file and later fumbling through xcodebuild flags to get it running on the simulator.