I am sure you have. I have had this issue every now and then with nearly all iOS and macOS versions. Never quite understood what fixed it and what broke it. I continued to ReStart both devices and ultimately decided that it is not the cable. What mostly worked for me (when it works) is also choosing one port on the Mac over another. I am sure that you have tried that as well.
One other option is putting the iMag in Safe Mode and then shutting down and then rebooting in normal mode. If you have not tried this then do so. Briefly putting the iMac in Safe Mode will clear some cache files which may (or may not) be affecting the function of what you are attempting to do.
Axel F.