Skip to content

* Update common lib so we can use debug command for iOS devices #239

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/definitions/project.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ interface IPlatformProjectService {
buildProject(projectRoot: string): IFuture<void>;
isPlatformPrepared(projectRoot: string): IFuture<boolean>;
addLibrary(platformData: IPlatformData, libraryPath: string): IFuture<void>;
getDebugOnDeviceSetup(): Mobile.IDebugOnDeviceSetup;
}
4 changes: 4 additions & 0 deletions lib/services/android-project-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ class AndroidProjectService implements IPlatformProjectService {
return this.$fs.exists(path.join(projectRoot, "assets", constants.APP_FOLDER_NAME));
}

public getDebugOnDeviceSetup(): Mobile.IDebugOnDeviceSetup {
return { };
}

private generateBuildFile(projDir: string, targetSdk: string): void {
this.$logger.info("Generate build.xml for %s", projDir);
var cmd = util.format("android update project -p %s --target %s --subprojects", projDir, targetSdk);
Expand Down
12 changes: 11 additions & 1 deletion lib/services/ios-project-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ class IOSProjectService implements IPlatformProjectService {
private $childProcess: IChildProcess,
private $errors: IErrors,
private $logger: ILogger,
private $iOSEmulatorServices: Mobile.IEmulatorPlatformServices) { }
private $iOSEmulatorServices: Mobile.IEmulatorPlatformServices,
private $npm: INodePackageManager) { }

public get platformData(): IPlatformData {
return {
Expand Down Expand Up @@ -194,6 +195,15 @@ class IOSProjectService implements IPlatformProjectService {
}).future<void>()();
}

public getDebugOnDeviceSetup(): Mobile.IDebugOnDeviceSetup {
var tnsIosPackage = this.$npm.install("tns-ios").wait();
var safariPath = path.join(tnsIosPackage, "WebInspectorUI/Safari/Main.html");

return {
frontEndPath: safariPath
}
}

private validateDynamicFramework(libraryPath: string): IFuture<void> {
return (() => {
var infoPlistPath = path.join(libraryPath, "Info.plist");
Expand Down
9 changes: 4 additions & 5 deletions lib/services/platform-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,22 +209,21 @@ export class PlatformService implements IPlatformService {
public debugOnDevice(platform: string): IFuture<void> {
return (() => {
platform = platform.toLowerCase();

var platformData = this.$platformsData.getPlatformData(platform);
var packageFile = "";

if (options["debug-brk"]) {
this.preparePlatform(platform).wait();

var platformData = this.$platformsData.getPlatformData(platform);

this.buildPlatform(platform).wait();

packageFile = this.getLatestApplicationPackageForDevice(platformData).wait().packageName;
this.$logger.out("Using ", packageFile);
}

var debugOnDeviceSetup = platformData.platformProjectService.getDebugOnDeviceSetup();

this.$devicesServices.initialize({platform: platform, deviceId: options.device}).wait();
var action = (device: Mobile.IDevice): IFuture<void> => { return device.debug(packageFile, this.$projectData.projectId); };
var action = (device: Mobile.IDevice): IFuture<void> => { return device.debug(packageFile, this.$projectData.projectId, debugOnDeviceSetup)};
this.$devicesServices.execute(action).wait();

}).future<void>()();
Expand Down