iPhone keeps disconnecting & connecting when transferring data

I have a MacBook Pro (2015), and an iPhone 7 Plus.

The problem is the following: If the iPhone is connected to my Mac, then whenever I run an app via XCode, or the Mac is just transferring data, the iPhone starts disconnecting and connecting (the battery icon indicates it), and the data transfer fails.


First I thought that this was a cable issue, because If I adjust the cable in a certain position then it works, but I realized that it is not:

because

  • I bought brand new cables

  • I cleaned the USB port of the Mac

But still nothing

It is really annoying.


Sometimes it gets fixed if I unplug & reinsert the USB like 5-7 times.


Solution 1:

  1. Disconnect your iPhone or iPad.
  2. Open Terminal and type
sudo killall -STOP -c usbd
  1. Happily connect again your devices.

Solution 2:

Tried really everything, the only thing that works is charging my iPhone to 100%, than the iPhone 11 or 8 does not disconnect anymore from my Mid 2015 Macbook. So and hoc connecting is a problem, as well as charging your phone via the laptop.