Six months before the first iPhone was released into the eager hands of the buying public, all Apple had was a glitzy demo of a product that, in reality, barely existed. There were still hundreds of problems—from tiny software bugs to seemingly insurmountable hardware hurdles—to be solved. Faced with a hard shipping deadline of June 29, Apple's employees scrambled as managers bickered and executives locked horns. This story of the 24 weeks, three days, and three hours leading up to the launch of the iPhone is excerpted from Fred Vogelstein's 2013 book, "Dogfight: How Apple and Google Went to War and Started a Revolution." Buy it on Amazon.

•••

Everyone agreed that Steve Jobs's iPhone demo back in January 2007 had been flawless—remarkable even. He'd taken a barely working iPhone prototype and, with some engineering sleight of hand, made millions want to buy one right away. But sleight of hand wouldn't cut it when the iPhone actually went on sale June 29. Consumers would expect it to work as flawlessly as Jobs made them look onstage. And the iPhone team knew they were going to need every hour between early January and that immovable on-sale date.

It may have looked like Jobs already had zillions of iPhones ready for sale. In truth, all Apple had was a few dozen dozen prototypes. And those prototypes were so fragile they couldn't withstand ordinary shipping from Apple's Asian factories, let alone daily use. They only made it to the iPhone January unveiling because an Apple executive had flown to Asia and flown back with them as carry-on luggage. "We had to figure out how to build iPhones in mass quantity," said Bob Borchers, Apple's then head of iPhone product marketing. Anyone can make one hundred of something. Making a million of them is something else altogether.

"How do you build and test antennas, for example?," he said. "Every unit that came off the production line would need to be tested and characterized because there is great variability in how antennas get built on an assembly line. That affects the radio performance." Apple was so obsessive about leaving nothing to chance that it actually designed and built its own testing setup at Apple headquarters to address these issues. "Then we brought Foxconn [Apple's Asian manufacturing partner] in and said, 'Replicate this five hundred times or whatever it takes to get it done.'"

Sarah Crichton Books

It wasn't simply a matter of refining and producing parts that worked right. Key features of the iPhone were far from perfected. Its memory and the virtual keyboard, already one of its most controversial features, still didn't work right. Touching the letter "e"—the most frequently used letter in the alphabet—often caused other letters to pop up around the keyboard. Instead of appearing instantly after being "typed," letters would emerge after annoying lags.

Microsoft CEO Steve Ballmer had been among the many declaring the iPhone a failed product because it didn't have a physical keyboard. Apple executives were worried too. They weren't comfortable using the keyboard either. "Everyone was concerned about touching on something that doesn't have any physical feedback," one of the executives said. But Jobs was unyielding on the issue. "Steve's rationale was just what he said onstage. 'You put keys on, and now you've got these fixed keys that don't work for every app. Worse, you've lost half your screen real estate.' So everyone understood that this was incredibly important to get right—a make-or-break kind of thing."

Apple needed to reengineer the iPhone's display screen too. While Jobs had decreed it would be glass, not plastic, and had found a source for the material the previous fall, it was not as simple a matter as swapping one screen for the other. While Corning supplied the glass, that was only one of many steps necessary to create a working iPhone touchscreen. The multitouch sensors had to be embedded in the glass, not just attached to it, in order to work correctly. But the process of embedding the sensors in glass was entirely different from embedding them in plastic.