Why does my Macbook Air automatically shut down when i connect my iPhone to it?
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.