From c9afb9faad6382712d4990b55710c0728b784351 Mon Sep 17 00:00:00 2001 From: Fatme Havaluova Date: Tue, 21 Jul 2015 19:09:42 +0300 Subject: [PATCH] Fix ios debugger for projects created with framework version lower than 1.2.0 --- lib/services/ios-debug-service.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/services/ios-debug-service.ts b/lib/services/ios-debug-service.ts index 3407f7459d..2938b7b14a 100644 --- a/lib/services/ios-debug-service.ts +++ b/lib/services/ios-debug-service.ts @@ -6,6 +6,7 @@ import stream = require("stream"); import path = require("path"); import http = require("http"); import Future = require("fibers/future"); +import semver = require("semver"); module notification { function formatNotification(bundleId: string, notification: string) { @@ -71,7 +72,8 @@ class IOSDebugService implements IDebugService { private $errors: IErrors, private $injector: IInjector, private $npmInstallationManager: INpmInstallationManager, - private $options: IOptions) { } + private $options: IOptions, + private $projectDataService: IProjectDataService) { } get platform(): string { return "ios"; @@ -142,6 +144,7 @@ class IOSDebugService implements IDebugService { }); awaitNotification(npc, notification.readyForAttach(projectId), 5000).wait(); } catch(e) { + this.$logger.trace(`Timeout error: ${e}`); this.$errors.failWithoutHelp("Timeout waiting for NativeScript debugger."); } @@ -205,9 +208,19 @@ class IOSDebugService implements IDebugService { private openDebuggingClient(): IFuture { return (() => { let inspectorPath = this.getInspectorPath().wait(); - let inspectorApplicationPath = path.join(inspectorPath, "NativeScript Inspector.app"); let inspectorSourceLocation = path.join(inspectorPath, "Safari/Main.html"); - let cmd = `open -a '${inspectorApplicationPath}' --args '${inspectorSourceLocation}' '${this.$projectData.projectName}'`; + let cmd: string = null; + + this.$projectDataService.initialize(this.$projectData.projectDir); + let platformData = this.$platformsData.getPlatformData(this.platform); + let frameworkVersion = this.$projectDataService.getValue(platformData.frameworkPackageName).wait().version; + if(semver.lt(frameworkVersion, "1.2.0")) { + cmd = `open -a Safari "${inspectorSourceLocation}"`; + } else { + let inspectorApplicationPath = path.join(inspectorPath, "NativeScript Inspector.app"); + cmd = `open -a '${inspectorApplicationPath}' --args '${inspectorSourceLocation}' '${this.$projectData.projectName}'`; + } + this.$childProcess.exec(cmd).wait(); }).future()(); }