When it comes to testing and debugging of iOS applications, the emulator cannot fully replace testing them on actual devices. Well, if you have the possibility to connect iPhone, iPad, etc. directly to your development machine, you don’t have to worry. But what if you needed to inspect an app running on a device which couldn’t be physically connected to your Mac?
Apple has added an option for wireless debugging in Xcode 9. But before you start, you should bear in mind several conditions:
Mac computer and iOS device should share the same network.
You should use Xcode 9.0 or later, macOS 10.12.4 or later, and iOS 11.0 or later.
Okay, now lets proceed to the actual steps that will help you enable a remote debugging:
- Open your project on Xcode.
- Select Window > Devices and Simulators.
- In the window that appears, click “Devices”.
- Link your device to your Mac via a USB cable.
- In the left column, choose the device, and in the detail area, check the box “Connect via network”.
Now, Xcode will pair with your device. If Xcode can connect with the device over the network, a network icon will appear next to the device in the left column and you can safely disconnect your device.
If the first condition is not met and the device does not share the same network as Mac or even located miles away from the machine, remote debug with the help of Xcode will not be possible.
However, there is a workaround! You will still be able to debug such device with the help of USB over Ethernet redirection software, e.g. FlexiHub. It is designed to virtualize USB devices, (like iPhone, iPad, iPod, etc.) and redirect them over the network. The software works across LAN, Ethernet, and the Internet.
- To establish a remote connection to the iOS device, download and install Flexihub on both the local machine running the debugger and a remote computer with the iOS device physically attached.
- Launch FlexiHub on the local machine and register an account - click ‘Sign up’ link and follow the instructions. Sign into the account.
- Start the software on the remote computer and log into FlexiHub account using the same credentials.
- In the software interface on the local Mac, you’ll see iPhone/iPad available for connection. Click “Connect”.
That’s it. Now you can access the remote iOS device from your local computer and start the debugging process as though the device was directly connected to your machine.