I'm going to say something controversial: the most productive thing you can do when you hit a bug is close your laptop, stand up, and restart your computer. Not after twenty minutes of investigation. Not after adding a breakpoint. Immediately. Before you even read the error message.
I call this Reboot-First Debugging (RFD), and I have a 34% success rate, which I maintain is excellent for any debugging methodology.
"A watched Xcode never builds. But a restarted Mac often surprises you."
The RFD Decision Tree
- Have you tried restarting Xcode? → Yes → Have you tried restarting your Mac? → Yes → Have you tried restarting the build server? → Yes → Have you tried restarting the client's Mac? → Yes → Ship it, the bug is theirs now.
In a study I conducted on myself over six months, 34% of bugs resolved themselves following a restart. Another 28% were still present but somehow felt less urgent after the reboot. The remaining 38% I filed as "known issues" and moved on with my life.
Common Objections
"But restarting loses my debugging context." Your debugging context is the problem. It's full of bad assumptions and four-hour sunk cost bias. A fresh boot is a fresh mind.
"The bug is a logic error. Restarting won't help." You don't know that. Neither do I. Neither does the computer. Let's all find out together.
"I've been restarting for three days and the bug is still there." You're not restarting correctly. Are you doing a full shutdown, or just a restart? Are you unplugging external monitors? Have you tried restarting your router? What about your chair?
#!/bin/bash # RFD Automation Script — cron this for maximum effectiveness echo "Checking for bugs..." echo "Bugs found. Initiating RFD protocol." sudo shutdown -r now "fixing bugs"
I've also been experimenting with restarting my test devices, my CI server, my standing desk (unplugging and replugging the motor), and once, memorably, my marriage. Two of those four things are going better since the restart. I'll let you determine which two.