11import * as path from "path" ;
22import { ChildProcess } from "child_process" ;
33import { DebugServiceBase } from "./debug-service-base" ;
4- import { CONNECTION_ERROR_EVENT_NAME } from "../constants" ;
4+ import { CONNECTION_ERROR_EVENT_NAME , DeviceConnectionType } from "../constants" ;
55const inspectorAppName = "NativeScript Inspector.app" ;
66const inspectorNpmPackageName = "tns-ios-inspector" ;
77const 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