The other answers to this question as of writing this answer are now somewhat outdated – you can't manually uninstall iTunes without disabling SIP on El Capitan and newer macOS versions, and I would not recommend disabling SIP to delete iTunes. Continue reading this answer for an updated method.
If your iPhone isn't showing up on iTunes on macOS, you may reinstall iTunes by downloading the installer from here. Note that this will work on newer macOS versions such as El Capitan, Sierra, and High Sierra. You do not need to disable System Integrity Protection to do this.
As a matter of fact, this is what solved my issue on a Mac with High Sierra. My iPhone wasn't showing up in iTunes or Xcode, but reinstalling iTunes allowed it to show up again.
If, however, you issue isn't solved by reinstalling iTunes, there are a myriad of things you could try. In order to diagnose my own issue I made a list of things you could try, which you can find below. Some of these points may solve your issue. Some allow you to diagnose what might be causing the issue; these will thereby help you to isolate the cause and hopefully be able to fix it.
For macOS and Windows
- Take a look at Apple's own guide for troubleshooting the issue (advice for both macOS and Windows is available here).
- Try a different, certified lightning cable. A lightning cable might stop working (even if your device charges). Using an uncertified (non-MFi) cable can cause unexpected behavior such as preventing your iPhone from showing up in iTunes.
- Try connecting your iPhone to a different computer. Connect it to another Mac; does it show up there? What about on a Windows PC? If it shows up on another computer, there might be something wrong with your own computer. Try looking at Apple's guide above if this is the case.
- Try connecting another iPhone to your computer. Does it show up? If it does, there might be something wrong with your main iPhone. If it doesn't, it might mean that iTunes on your computer doesn't want to display any devices. You can confirm this by checking the previous point.
- Try restarting iTunes. If that doesn't work, try restarting your iPhone or your computer. Perhaps it'll show up after a reboot.
- Try different USB ports on your computer, in the case that one is faulty.
- If you have any third-party iPhone managers installed such as AnyTrans, iMazing, or iFunBox, try seeing whether the device shows up there. You may also try other apps that work by detecting your iPhone and see if they can still detect it (such as coconutBattery).
- Unlock your device and see if any computer trust popup shows up.
- Is the iPhone or computer running on beta software? If so, that might be causing unexpected problems. Either upgrade to the latest beta or downgrade to the latest stable release (usually the latter will work).
- Put your iPhone in DFU mode (if you have an iPhone 7, you need to see the special instructions on the bottom of that page). After putting it successfully in DFU mode, does it show up in iTunes? If it does, then your cable most likely works. If it doesn't, try plugging it in (while it's in DFU mode) into another computer, with another cable, or into a different USB port.
- Reset your iPhone privacy settings, which resets computer trust settings. Warning: this is not guaranteed to solve the issue, and will cause all your privacy settings to be deleted. I recommend your open your essential apps (camera, GPS apps, communication apps, etc.) and allow permissions so that you don't have to deal with them later (I once reset my settings and the camera location popup didn't show up, which meant a lot of pictures weren't geotagged).
For macOS only
- Open System information (located at
/Applications/Utilities/System Information.app) and click the USB tab on the left. Does "iPhone" anywhere in the USB tree view? If it does, your Mac recognizes that an iPhone is connected to it, even if iTunes doesn't.
- Open the Image Capture (located at
/Applications/Image Capture.app). Does it recognize your device?
- If you have Xcode installed, try seeing if your device is recognized by it.
For Windows only
- Does your iPhone show up as a device in Device manager?
- The best advice I would suggest on Windows would be to follow Apple's guide on troubleshooting this issue on Windows which I linked above.
- If nothing seems to work, try reinstalling iTunes.
Even if these suggestions don't help you fix your problem, they'll give you an idea about what's causing the problem. Is it your device, your cable, or your computer? What about these may the problem be? Hopefully with the new information you'll be able to come to a better informed decision as to how to go about fixing the problem.