1
1
import * as path from "path" ;
2
2
import { ChildProcess } from "child_process" ;
3
3
import { DebugServiceBase } from "./debug-service-base" ;
4
- import { CONNECTION_ERROR_EVENT_NAME } from "../constants" ;
4
+ import { CONNECTION_ERROR_EVENT_NAME , DeviceConnectionType } from "../constants" ;
5
5
const inspectorAppName = "NativeScript Inspector.app" ;
6
6
const inspectorNpmPackageName = "tns-ios-inspector" ;
7
7
const inspectorUiDir = "WebInspectorUI/" ;
@@ -33,7 +33,7 @@ export class IOSDeviceDebugService extends DebugServiceBase implements IDeviceDe
33
33
@performanceLog ( )
34
34
public async debug ( debugData : IDebugData , debugOptions : IDebugOptions ) : Promise < IDebugResultInfo > {
35
35
const result : IDebugResultInfo = { debugUrl : null } ;
36
- this . validateOptions ( debugOptions ) ;
36
+ await this . validateOptions ( debugOptions ) ;
37
37
38
38
result . debugUrl = await this . wireDebuggerClient ( debugData , debugOptions ) ;
39
39
@@ -44,14 +44,24 @@ export class IOSDeviceDebugService extends DebugServiceBase implements IDeviceDe
44
44
this . $appDebugSocketProxyFactory . removeAllProxies ( ) ;
45
45
}
46
46
47
- private validateOptions ( debugOptions : IDebugOptions ) {
47
+ private async validateOptions ( debugOptions : IDebugOptions ) {
48
48
if ( ! this . $hostInfo . isWindows && ! this . $hostInfo . isDarwin ) {
49
49
this . $errors . fail ( `Debugging on iOS devices is not supported for ${ platform ( ) } yet.` ) ;
50
50
}
51
51
52
52
if ( debugOptions . debugBrk && debugOptions . start ) {
53
53
this . $errors . fail ( "Expected exactly one of the --debug-brk or --start options." ) ;
54
54
}
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
+ }
55
65
}
56
66
57
67
private getProjectName ( debugData : IDebugData ) : string {
0 commit comments