Go to home page
Toxin
EN

Keep Mac awake during a build: Xcode and Docker on macOS

The build takes forty minutes. You start it, get a coffee and come back to a Mac that has been asleep for twenty.

Why builds in particular

A build maxes out the processor and still produces not a single input. macOS decides on sleep by the time without key presses or mouse movement, not by the load. To the system, nobody is at the computer.

Whether Xcode or a build tool takes out an assertion itself depends on the tool and on how it is invoked. If you have not checked, do not rely on it.

What happens when it falls asleep

When the Mac sleeps, the build stops. On wake it often simply carries on, but not always: network connections have usually dropped, and a step that was fetching dependencies fails with a timeout.

Docker adds another layer. The containers run in a virtual machine that sleeps with the Mac. What fails afterwards rarely looks like sleep; it looks like a random network error.

Two ways to let it run through

In Terminal, caffeinate -i keeps the Mac awake for exactly as long as a command runs, for example caffeinate -i make. It is precise, but you have to put it in front of the command every time.

With Toxin you start a span before the build that comfortably exceeds the expected length, or an indefinite session for builds with no foreseeable end. The time remaining is in the panel; afterwards, whatever System Settings say applies again.

Overnight and with the lid closed

For an overnight build, a twelve-hour span is enough. Toxin keeps the display on as well; if you do not need it, turn the brightness down.

If you close the MacBook during the build, you need lid mode, because closing the lid is a separate rule in macOS. A build at full load gets warm with the lid closed; the Mac should lie in the open, not in a bag.

If the build breaks anyway

  • Check the icon: outlined means no session was running.
  • Span too short? Look at the end time in the panel.
  • Lid closed without lid mode? Then macOS put the Mac to sleep.
  • Network error halfway through? It is often the trace of a sleep.

Common questions

Isn’t caffeinate enough?

For single commands in Terminal, yes. Toxin is more convenient when the build runs from Xcode, another app or several steps and you do not want to rewrite every invocation.

Does Toxin slow the build down?

No. Toxin only takes out an assertion and computes nothing else. The build gets the same performance as without it.

A broken build rarely costs compute time; it costs attention. Toxin keeps your Mac awake for as long as you want — a menu bar app for macOS, not on the Mac App Store yet.

Home