My iPhone keeps switching on and off charge whilst charging, how do I fix it? When I charge my iPhone 4 on my laptop, it starts charging but then it keeps going on and off charging even though it's not touched.
It charges fine with a plug charger or with any computers I use at college.

What things prevent a Mac from charging a connected iPhone so that charging can be resumed?
Running this in terminal worked for me: (it will ask for your user's password)

sudo killall -STOP -c usbd


This pauses the troublesome process instead of killing it altogether like other answers suggest. The difference is that macOS won't try to reopen it automatically and cause the issue again.

Running sudo killall -CONT usbd will resume the process, should anything require it.

Tested on: iPhone 7 (iOS 11) + MacBook Pro Late 2013 (10.13.6)



Besides software issues, there's a good chance that the cable is at least partially damaged so it might work for dumb power chargers but not with a MacBook that also relies on the USB data pins.



Also this might happen when either device needs an update. I've been asked "Install update to connect to device?" before and if I don't accept, this issue happens.