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