From 5d79aeb2ca27ab15758729161632ff1f8bee0951 Mon Sep 17 00:00:00 2001 From: rosen-vladimirov Date: Mon, 17 Jun 2019 18:12:17 +0300 Subject: [PATCH 1/2] fix: hmr for iOS does not work on Windows With `tns cloud run ...` command (or with NativeScript Sidekick), you can use LiveSync on iOS device from Windows machine (with application built in the cloud). However, this approach does not work when the iOS device does not have developer disk image mounted (i.e. it has not been used on macOS). The problem is that during establishment of socket connection, CLI tries to start the application. This is a precautions for cases when the application had crashed. In most of the cases when we reach to this code, the application is already up and running. However, calling `startApplication` fails on Windows and we never setup the socket connection. So the HMR does not work at all. Fix this by adding a try-catch block around starting of application when trying to setup the socket connection. --- lib/common/mobile/ios/device/ios-device.ts | 1 + lib/common/mobile/ios/ios-device-base.ts | 9 +++++++-- lib/common/mobile/ios/simulator/ios-simulator-device.ts | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/common/mobile/ios/device/ios-device.ts b/lib/common/mobile/ios/device/ios-device.ts index e10a589114..3e75d06f8b 100644 --- a/lib/common/mobile/ios/device/ios-device.ts +++ b/lib/common/mobile/ios/device/ios-device.ts @@ -18,6 +18,7 @@ export class IOSDevice extends IOSDeviceBase { private $injector: IInjector, protected $iOSDebuggerPortService: IIOSDebuggerPortService, protected $deviceLogProvider: Mobile.IDeviceLogProvider, + protected $logger: ILogger, protected $lockService: ILockService, private $iOSSocketRequestExecutor: IiOSSocketRequestExecutor, private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants, diff --git a/lib/common/mobile/ios/ios-device-base.ts b/lib/common/mobile/ios/ios-device-base.ts index 62be589cfc..302f7d4112 100644 --- a/lib/common/mobile/ios/ios-device-base.ts +++ b/lib/common/mobile/ios/ios-device-base.ts @@ -7,6 +7,7 @@ export abstract class IOSDeviceBase implements Mobile.IiOSDevice { protected abstract $deviceLogProvider: Mobile.IDeviceLogProvider; protected abstract $iOSDebuggerPortService: IIOSDebuggerPortService; protected abstract $lockService: ILockService; + protected abstract $logger: ILogger; abstract deviceInfo: Mobile.IDeviceInfo; abstract applicationManager: Mobile.IDeviceApplicationManager; abstract fileSystem: Mobile.IDeviceFileSystem; @@ -22,8 +23,12 @@ export abstract class IOSDeviceBase implements Mobile.IiOSDevice { } await this.attachToDebuggerFoundEvent(appId, projectName); - if (ensureAppStarted) { - await this.applicationManager.startApplication({ appId, projectName }); + try { + if (ensureAppStarted) { + await this.applicationManager.startApplication({ appId, projectName }); + } + } catch (err) { + this.$logger.trace(`Unable to start application ${appId} on device ${this.deviceInfo.identifier} in getDebugSocket method. Error is: ${err}`); } this.cachedSockets[appId] = await this.getDebugSocketCore(appId); diff --git a/lib/common/mobile/ios/simulator/ios-simulator-device.ts b/lib/common/mobile/ios/simulator/ios-simulator-device.ts index 50a178d4f3..e6b6cbf02b 100644 --- a/lib/common/mobile/ios/simulator/ios-simulator-device.ts +++ b/lib/common/mobile/ios/simulator/ios-simulator-device.ts @@ -22,7 +22,7 @@ export class IOSSimulator extends IOSDeviceBase implements Mobile.IiOSDevice { private $iOSEmulatorServices: Mobile.IiOSSimulatorService, private $iOSNotification: IiOSNotification, private $iOSSimulatorLogProvider: Mobile.IiOSSimulatorLogProvider, - private $logger: ILogger) { + protected $logger: ILogger) { super(); this.applicationManager = this.$injector.resolve(applicationManagerPath.IOSSimulatorApplicationManager, { iosSim: this.$iOSSimResolver.iOSSim, device: this }); this.fileSystem = this.$injector.resolve(fileSystemPath.IOSSimulatorFileSystem, { iosSim: this.$iOSSimResolver.iOSSim }); From cbb8ac83c691dd86e52a64d5281c88af64c1b6be Mon Sep 17 00:00:00 2001 From: rosen-vladimirov Date: Mon, 17 Jun 2019 18:17:46 +0300 Subject: [PATCH 2/2] chore: set version to 5.4.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 93304186f6..59f557644b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nativescript", "preferGlobal": true, - "version": "5.4.1", + "version": "5.4.2", "author": "Telerik ", "description": "Command-line interface for building NativeScript projects", "bin": {