From 8380a0253080d51b91fa264d27fb758ccb8e65cd Mon Sep 17 00:00:00 2001 From: Kristina Koeva Date: Mon, 12 Oct 2015 12:07:44 +0300 Subject: [PATCH 1/3] Pass wait for debugger option. Handle simulator output so that we could retrieve the PID of the running application. If you break on a line before executing UIApplicationMain, the Simulator crashes the app after a few seconds. To workaround that behavior we attach lldb which must be killed after the debugging session ends. --- lib/services/ios-debug-service.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/services/ios-debug-service.ts b/lib/services/ios-debug-service.ts index cb6fdad1f5..5f865e3807 100644 --- a/lib/services/ios-debug-service.ts +++ b/lib/services/ios-debug-service.ts @@ -10,6 +10,8 @@ import * as path from "path"; import Future = require("fibers/future"); import semver = require("semver"); import temp = require("temp"); +import byline = require("byline"); + module notification { function formatNotification(bundleId: string, notification: string) { @@ -118,7 +120,20 @@ class IOSDebugService implements IDebugService { this.$platformService.buildPlatform(this.platform).wait(); let emulatorPackage = this.$platformService.getLatestApplicationPackageForEmulator(platformData).wait(); - this.$iOSEmulatorServices.startEmulator(emulatorPackage.packageName, { args: "--nativescript-debug-brk" }).wait(); + let child_process = this.$iOSEmulatorServices.startEmulator(emulatorPackage.packageName, { waitForDebugger: true, captureStdin: true, args: "--nativescript-debug-brk" }).wait(); + let lineStream = byline(child_process.stdout); + + lineStream.on('data', (line: NodeBuffer) => { + let lineText = line.toString(); + if(lineText && _.startsWith(lineText, emulatorPackage.packageName)) { + let pid = _.trimLeft(lineText, emulatorPackage.packageName + ": "); + + this.$childProcess.exec(`lldb -p ${pid} -o "process continue"`); + } else { + process.stdout.write(line + "\n"); + } + }); + this.wireDebuggerClient(() => net.connect(InspectorBackendPort)).wait(); }).future()(); } From a088373fc32e080179e3ae5173c22513317988f3 Mon Sep 17 00:00:00 2001 From: Kristina Koeva Date: Mon, 12 Oct 2015 12:46:03 +0300 Subject: [PATCH 2/3] Update submodule --- lib/common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/common b/lib/common index 649967a2f1..594b2f27b4 160000 --- a/lib/common +++ b/lib/common @@ -1 +1 @@ -Subproject commit 649967a2f1732f7bc710fd59cf617b6603dc7b1c +Subproject commit 594b2f27b4edf2f133f96515fafb8b7f815f50f6 From ec1fc60466de05ef22a4beaf89c8e9e970e8ffd7 Mon Sep 17 00:00:00 2001 From: Kristina Koeva Date: Mon, 12 Oct 2015 14:35:56 +0300 Subject: [PATCH 3/3] Fix styling and update dependencies --- lib/common | 2 +- lib/services/ios-debug-service.ts | 7 +++---- package.json | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/common b/lib/common index 594b2f27b4..7f0774504c 160000 --- a/lib/common +++ b/lib/common @@ -1 +1 @@ -Subproject commit 594b2f27b4edf2f133f96515fafb8b7f815f50f6 +Subproject commit 7f0774504c7660c1444ae204c00cf3b7c908292c diff --git a/lib/services/ios-debug-service.ts b/lib/services/ios-debug-service.ts index 5f865e3807..30988f3711 100644 --- a/lib/services/ios-debug-service.ts +++ b/lib/services/ios-debug-service.ts @@ -12,7 +12,6 @@ import semver = require("semver"); import temp = require("temp"); import byline = require("byline"); - module notification { function formatNotification(bundleId: string, notification: string) { return `${bundleId}:NativeScript.Debug.${notification}`; @@ -125,15 +124,15 @@ class IOSDebugService implements IDebugService { lineStream.on('data', (line: NodeBuffer) => { let lineText = line.toString(); - if(lineText && _.startsWith(lineText, emulatorPackage.packageName)) { + if(lineText && _.startsWith(lineText, emulatorPackage.packageName)) { let pid = _.trimLeft(lineText, emulatorPackage.packageName + ": "); - + this.$childProcess.exec(`lldb -p ${pid} -o "process continue"`); } else { process.stdout.write(line + "\n"); } }); - + this.wireDebuggerClient(() => net.connect(InspectorBackendPort)).wait(); }).future()(); } diff --git a/package.json b/package.json index 6f364a47b9..8e491d8dcc 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "gulp": "3.9.0", "iconv-lite": "0.4.11", "inquirer": "0.9.0", - "ios-sim-portable": "1.0.9-beta", + "ios-sim-portable": "1.0.10-alpha", "lockfile": "1.0.1", "lodash": "3.10.0", "log4js": "0.6.26",