Skip to content

Commit 1ce8d9e

Browse files
FatmeFatme
Fatme
authored and
Fatme
committed
Merge pull request #668 from NativeScript/fatme/fix-ios-debugger
Fix ios debugger for projects created with framework version lower than 1.2.0…
2 parents 52efd25 + c9afb9f commit 1ce8d9e

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

lib/services/ios-debug-service.ts

+16-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import stream = require("stream");
66
import path = require("path");
77
import http = require("http");
88
import Future = require("fibers/future");
9+
import semver = require("semver");
910

1011
module notification {
1112
function formatNotification(bundleId: string, notification: string) {
@@ -71,7 +72,8 @@ class IOSDebugService implements IDebugService {
7172
private $errors: IErrors,
7273
private $injector: IInjector,
7374
private $npmInstallationManager: INpmInstallationManager,
74-
private $options: IOptions) { }
75+
private $options: IOptions,
76+
private $projectDataService: IProjectDataService) { }
7577

7678
get platform(): string {
7779
return "ios";
@@ -142,6 +144,7 @@ class IOSDebugService implements IDebugService {
142144
});
143145
awaitNotification(npc, notification.readyForAttach(projectId), 5000).wait();
144146
} catch(e) {
147+
this.$logger.trace(`Timeout error: ${e}`);
145148
this.$errors.failWithoutHelp("Timeout waiting for NativeScript debugger.");
146149
}
147150

@@ -205,9 +208,19 @@ class IOSDebugService implements IDebugService {
205208
private openDebuggingClient(): IFuture<void> {
206209
return (() => {
207210
let inspectorPath = this.getInspectorPath().wait();
208-
let inspectorApplicationPath = path.join(inspectorPath, "NativeScript Inspector.app");
209211
let inspectorSourceLocation = path.join(inspectorPath, "Safari/Main.html");
210-
let cmd = `open -a '${inspectorApplicationPath}' --args '${inspectorSourceLocation}' '${this.$projectData.projectName}'`;
212+
let cmd: string = null;
213+
214+
this.$projectDataService.initialize(this.$projectData.projectDir);
215+
let platformData = this.$platformsData.getPlatformData(this.platform);
216+
let frameworkVersion = this.$projectDataService.getValue(platformData.frameworkPackageName).wait().version;
217+
if(semver.lt(frameworkVersion, "1.2.0")) {
218+
cmd = `open -a Safari "${inspectorSourceLocation}"`;
219+
} else {
220+
let inspectorApplicationPath = path.join(inspectorPath, "NativeScript Inspector.app");
221+
cmd = `open -a '${inspectorApplicationPath}' --args '${inspectorSourceLocation}' '${this.$projectData.projectName}'`;
222+
}
223+
211224
this.$childProcess.exec(cmd).wait();
212225
}).future<void>()();
213226
}

0 commit comments

Comments
 (0)