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.
Connecting your Android device via WiFi
- Connect your device normally via USB cable.
- Ensure the connection is successful by typing adb devices in a command line window.
- In the same command line, type adb tcpip 5555 to switch ports.
- You’ll get the message: restarting in TCP mode port: 5555 after a few seconds.
- Find out the device’s current WiFi IP address:
- In older Android devices, tap and hold the WiFi icon and tap your current network.
- In newer Android devices, go to WiFi > Advanced, and locate the IPv4 address.
- Disconnect the USB cable.
- Type adb connect 192.168.0.x to connect wirelessly using the IP from your device.
- Type adb devices and press enter, your device should appear in the list.
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.
To disconnect, type adb disconnect in the command line, or restart your device.
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
- Connect your device normally via USB cable
- Open Xcode and go to Window > Devices and Simulators
- Check the Connect via Network option and wait a few seconds
- Disconnect the USB cable
- Your device should still appear in the Devices list while connected via WiFi
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.