Prevent iPhone from charging when plugged into a battery powered MacBook Air
I don't know if there is a software way to do that, but there is an hardware way:


Use an unpowered USB cable (some company makes it, targeting audiophiles), might need an adapter to male lightning.
Tape/Remove the power plugs on your USB cable.


Also, not exactly an answer to your question, but maybe to your use-case:
Build a binary, then export it to iTunes, then upload via wifi.
No debbuger and much less convenient tho.