I hope Apple figure it out and fix it in new updates, however, I've seen that people have had this problem from 2013. I have done everything and nothing fixed it. I specify that I have a 256Go iPhone X under IOS 11.2.5 and a 13' retina Macbook pro (mid 2014) under High Sierra 10.13.3. I reseted location and privacy of my phone ( Devices rapidly disconnect/reconnect - Macbook Air Mid 2013). I shut down and turned on my computer and my phone. Here everything I tried to resolve this issue (which failed by the way) : I plugged in my iPhone to my brother's former Macbook pro (15' from 2008) and my iPhone could charge normally. I plugged in my mother's iPhone 6 to my Macbook and it charged perfectly. I tried to connect my iPhone to both USB ports of my Macbook, with many different Apple lightning cables and also my Anker cable (MFI certified), but the issue substains. I also noticed that there is a lag time before my phone starts charging when connected to my Macbook (before disconnecting right away, and then reconnecting etc). However when I plug in my iPhone to a wall outlet, it charges perfectly. I own this iPhone since decembre 2018, and this issue only appeared this week. Therefore I cannot charge my phone through my computer anymore.
When I plug in my iPhone to my Macbook pro, it repetitively connects and disconnects.