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.
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.