Skip to content

Commit c48a401

Browse files
committed
fix: forbid debugging on Wi-Fi devices as we are not able to connect to their debug socket
1 parent 639a000 commit c48a401

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

lib/services/ios-device-debug-service.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as path from "path";
22
import { ChildProcess } from "child_process";
33
import { DebugServiceBase } from "./debug-service-base";
4-
import { CONNECTION_ERROR_EVENT_NAME } from "../constants";
4+
import { CONNECTION_ERROR_EVENT_NAME, DeviceConnectionType } from "../constants";
55
const inspectorAppName = "NativeScript Inspector.app";
66
const inspectorNpmPackageName = "tns-ios-inspector";
77
const inspectorUiDir = "WebInspectorUI/";
@@ -33,7 +33,7 @@ export class IOSDeviceDebugService extends DebugServiceBase implements IDeviceDe
3333
@performanceLog()
3434
public async debug(debugData: IDebugData, debugOptions: IDebugOptions): Promise<IDebugResultInfo> {
3535
const result: IDebugResultInfo = { debugUrl: null };
36-
this.validateOptions(debugOptions);
36+
await this.validateOptions(debugOptions);
3737

3838
result.debugUrl = await this.wireDebuggerClient(debugData, debugOptions);
3939

@@ -44,14 +44,24 @@ export class IOSDeviceDebugService extends DebugServiceBase implements IDeviceDe
4444
this.$appDebugSocketProxyFactory.removeAllProxies();
4545
}
4646

47-
private validateOptions(debugOptions: IDebugOptions) {
47+
private async validateOptions(debugOptions: IDebugOptions) {
4848
if (!this.$hostInfo.isWindows && !this.$hostInfo.isDarwin) {
4949
this.$errors.fail(`Debugging on iOS devices is not supported for ${platform()} yet.`);
5050
}
5151

5252
if (debugOptions.debugBrk && debugOptions.start) {
5353
this.$errors.fail("Expected exactly one of the --debug-brk or --start options.");
5454
}
55+
56+
await this.validateUSBConnectedDevice();
57+
}
58+
59+
private async validateUSBConnectedDevice() {
60+
const device = await this.$devicesService.getDevice(this.deviceIdentifier);
61+
if (device.deviceInfo.connectionTypes.indexOf(DeviceConnectionType.USB) === -1) {
62+
const deviceConnectionTypes = device.deviceInfo.connectionTypes.map(type => DeviceConnectionType[type]).join(", ");
63+
this.$errors.fail(`Debugging application requires a USB connection while the target device "${this.deviceIdentifier}" has connection type "${deviceConnectionTypes}".`);
64+
}
5565
}
5666

5767
private getProjectName(debugData: IDebugData): string {

0 commit comments

Comments
 (0)