How to connect Android or iPhone via WiFi for application deployment

Developing mobile apps using Apache Cordova or any other platform involves constantly deploying your app to real devices. This process can become tedious because the phone or tablet must be connected via USB cable to your computer. However, you can connect your device via WiFi and deploy and debug your app normally following these steps.

WiFi Android iPhone Apple Phonegap

Connecting your Android device via WiFi

  1. Connect your device normally via USB cable.
  2. Ensure the connection is successful by typing adb devices in a command line window.
  3. In the same command line, type adb tcpip 5555  to switch ports.
    1. You’ll get the message: restarting in TCP mode port: 5555 after a few seconds.
  4. Find out the device’s current WiFi IP address:
    1. In older Android devices, tap and hold the WiFi icon and tap your current network.
    2. In newer Android devices, go to WiFi > Advanced, and locate the IPv4 address.
  5. Disconnect the USB cable.
  6. Type adb connect 192.168.0.x  to connect wirelessly using the IP from your device.
  7. Type adb devices  and press enter, your device should appear in the list.
android 5 wifi IP

How to find out your IP in newer Android devices

Below is a sample command line with the previous commands executed. The device is now connected by WiFi and you can deploy and debug your apps normally, without cables.

Steps to connect your Android device via WiFi.

To disconnect, type adb disconnect  in the command line, or restart your device.

Troubleshooting

If your device does not appear in the list, or you get connection errors, restart either Windows and / or the device itself and retry the process.

Connecting your iOS device via WiFi to Xcode

  1. Connect your device normally via USB cable
  2. Open Xcode and go to Window > Devices and Simulators
  3. Check the Connect via Network option and wait a few seconds
  4. Disconnect the USB cable
  5. Your device should still appear in the Devices list while connected via WiFi
Xcode Devices and Simulators

Checking the Connect via Network option will connect your device via WiFi

Troubleshooting

If you receive errors connecting the device via WiFi or it does not appear to be connected anymore, restart the device and Xcode. If the problem persists, try to restart your Mac as well.

How to debug your Cordova Android app