Skip to content

Commit b2301d1

Browse files
rosen-vladimirovdtopuzov
authored andcommitted
Fix tns debug ios --justlaunch (#2758)
When `--justlaunch` flag is passed, CLI automatically disposes the `ios-device-lib` after execution of the command. However this closes all opened device sockets and breaks the debug command. So whenever you try `tns debug ios --justlaunch [--chrome]`, the debug application (NativeScript Inspector) or Chrome DevTools is unable to connect to device socket and fails with error. Fix this by keeping the `ios-device-lib` alive whenever we try debug for ios. This way the debug application will be able to connect to the device. NOTE: `tns debug ios --justlaunch [--chrome]` cannot release the terminal as it has to keep the ios-device-lib alive.
1 parent 5c5f307 commit b2301d1

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/commands/debug.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,11 @@ export class DebugIOSCommand extends DebugPlatformCommand {
103103
$platformsData: IPlatformsData,
104104
$iosDeviceOperations: IIOSDeviceOperations) {
105105
super($iOSDebugService, $devicesService, $injector, $devicePlatformsConstants, $config, $usbLiveSyncService, $debugDataService, $platformService, $projectData, $options, $platformsData, $logger);
106-
$iosDeviceOperations.setShouldDispose(this.$options.justlaunch);
106+
// Do not dispose ios-device-lib, so the process will remain alive and the debug application (NativeScript Inspector or Chrome DevTools) will be able to connect to the socket.
107+
// In case we dispose ios-device-lib, the socket will be closed and the code will fail when the debug application tries to read/send data to device socket.
108+
// That's why the `$ tns debug ios --justlaunch` command will not release the terminal.
109+
// In case we do not set it to false, the dispose will be called once the command finishes its execution, which will prevent the debugging.
110+
$iosDeviceOperations.setShouldDispose(false);
107111
}
108112

109113
public async canExecute(args: string[]): Promise<boolean> {

0 commit comments

Comments
 (0)