Assuming the device is compatible (not running a current beta), it should just be a matter of connecting it to your mac while Xcode is open, then responding to the dialog(s) ask if you want to use it.
When that process works, you can use the Xcode menu 'Devices and Simulators' to see your device/phone. If you can see it there but Xcode doesn't make it available to build to, check there that Xcode has allowed it.
If you're beyond that and still no joy, try restarting both your mac and the device.
With that X connected to your mac, do an 'About This Mac' from the Apple logo top left, then system report, then select USB/USB 3 bus and see if it lists an iPhone.
Finally, be sure you are using a quality cable that connects your X directly to a compatible USB port on your mac.