@@ -178,23 +178,30 @@ export class IOSDeviceDebugService extends DebugServiceBase implements IDeviceDe
178178 const existingTcpProxy = this . $appDebugSocketProxyFactory . getTCPSocketProxy ( this . deviceIdentifier , debugData . applicationIdentifier ) ;
179179 const tcpSocketProxy = existingTcpProxy || await this . $appDebugSocketProxyFactory . addTCPSocketProxy ( this . device , debugData . applicationIdentifier ) ;
180180 if ( ! existingTcpProxy ) {
181- await this . openAppInspector ( tcpSocketProxy . address ( ) , debugData , debugOptions ) ;
181+ const inspectorProcess = await this . openAppInspector ( tcpSocketProxy . address ( ) , debugData , debugOptions ) ;
182+ if ( inspectorProcess ) {
183+ tcpSocketProxy . on ( "close" , async ( ) => {
184+ await this . killProcess ( inspectorProcess ) ;
185+ } ) ;
186+ }
182187 }
183188
184189 return null ;
185190 }
186191
187- private async openAppInspector ( fileDescriptor : string , debugData : IDebugData , debugOptions : IDebugOptions ) : Promise < void > {
192+ private async openAppInspector ( fileDescriptor : string , debugData : IDebugData , debugOptions : IDebugOptions ) : Promise < ChildProcess > {
188193 if ( debugOptions . client ) {
189194 const inspectorPath = await this . $packageInstallationManager . getInspectorFromCache ( inspectorNpmPackageName , debugData . projectDir ) ;
190195
191196 const inspectorSourceLocation = path . join ( inspectorPath , inspectorUiDir , "Main.html" ) ;
192- const inspectorApplicationPath = path . join ( inspectorPath , inspectorAppName ) ;
197+ const inspectorApplicationPath = path . join ( inspectorPath , inspectorAppName , "Contents" , "MacOS" , inspectorAppName , "Contents" , "MacOS" , "NativeScript Inspector" ) ;
193198
194- const cmd = `open -a '${ inspectorApplicationPath } ' --args '${ inspectorSourceLocation } ' '${ debugData . projectName } ' '${ fileDescriptor } '` ;
195- await this . $childProcess . exec ( cmd ) ;
199+ const inspectorProcess : ChildProcess = this . $childProcess . spawn ( inspectorApplicationPath , [ inspectorSourceLocation , debugData . projectName , fileDescriptor ] ) ;
200+ inspectorProcess . on ( "error" , ( e : Error ) => this . $logger . trace ( e ) ) ;
201+ return inspectorProcess ;
196202 } else {
197203 this . $logger . info ( "Suppressing debugging client." ) ;
204+ return null ;
198205 }
199206 }
200207}
0 commit comments