It doesn't happen every time. The last time I connected my iPhone to my MacBook Air was last week, and everything was fine.
Sometimes my MacBook Air shuts down when I connect my iPhone to it. What should I do about this?
The Macbook Air tries to supply a full charging current to the iPhone, but when the Air is running on battery and doesn't have a full charge, it loads the battery down enough for the Air to go into low power mode.
When you connect you iPhone, make sure you have a full battery on the Air, or are plugged in. This will also happen less frequently if the iPhone battery is full, but the main issue is making sure the Air has enough power to give a full amp to the iPhone without shutting down.
This doesn't affect the larger notebooks as noticeably due to their larger battery packs, but as they age and when they have low charge you would see the same issue from them.
Have you checked if this happens with an specific cable and an specific port. Even a new device can have a faulty cable as I just bought an iPhone 4S, and the included cable shutdowns my MacBook Air just when I connect it to the right USB port of the MBA.