iPhone keeps connecting and disconnecting

Background

I occasionally do iOS application development, and in some cases want to test the application on my phone.

I have an iPhone XS and a 2015 Macbook Pro.

I am afflicted by the issue described here: https://www.ifixit.com/Answers/View/473839/iOS+devices+connecting+and+disconnecting+rapidly.

That is, when I connect my iPhone to my laptop via USB the computer shows the iPhone connecting and disconnecting rapidly. This makes it impossible to use as a test device.

I have tried, without success:

  • Using different cables, including genuine Apple ones.
  • Using both USB ports on the laptop.

What works reliably is using a powered USB hub. But carrying one of those around is inconvenient, and I don’t have one with me now.

The solutions listed in the thread include:

  • Trying a different cable.
  • Force quitting the usbd process.
  • Performing an SMC reset.
  • Charging phone to 100%.

I recall that force quitting usbd has worked for me in the past, but does not seem to work now. Force quitting usbd via activity monitor causes my phone to disappear from the Device Setup screen, and replugging causes the repeated disconnected behaviour to resume.

A solution

I ran the following in the terminal:

sudo killall -STOP -c usbd

And noticed that although the Device Setup screen didn’t list my phone, the Next button was still enabled. Clicking Next allowed me to build and run my app on my phone.

Running this command from the command line should do the same thing as force quit in activity monitor. More testing is required to see whether using force quit in activity monitor allows this behaviour.