How dose Apple get the latest iOS on new phones?

Apple shipped about 10 million phones this week. The iOS was not complete until a few days ago. The phones had to be made weeks or months ago, before the final version of iOS8 was available. How was Apple able to update all of these new phones (that are in packaging), with the most recent ios8?
They could have a system to flash the phone with new iOS in a few minutes (not the same way we install our update). This GM build was ready for at least 2 weeks, which gave them some lead. And a ton of workers working 24/24.
Phones are probably set up on some sort of queued system where once the software is finalized the phones upload on the factory automatically over a wifi system and are quickly inspected before they leave the factory. This is where the workers will drop the phones and put them back in the box and people will start threads caused they received a mini scratch out of the box hahaha
Steve Jobs' reality distortion?

Original thread: https://forums.imore.com/threads/how-dose-apple-get-the-latest-ios-on-new-phones.299325/