Skip to content

Fix tns run ios --justlaunch #3657

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

Merged
merged 2 commits into from
Jun 14, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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/livesync.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ interface IPlatformLiveSyncService {
fullSync(syncInfo: IFullSyncInfo): Promise<ILiveSyncResultInfo>;
liveSyncWatchAction(device: Mobile.IDevice, liveSyncInfo: ILiveSyncWatchInfo): Promise<ILiveSyncResultInfo>;
refreshApplication(projectData: IProjectData, liveSyncInfo: ILiveSyncResultInfo): Promise<void>;
prepareForLiveSync(device: Mobile.IDevice, data: IProjectDir, liveSyncInfo: ILiveSyncInfo): void;
}

interface INativeScriptDeviceLiveSyncService extends IDeviceLiveSyncServiceBase {
Expand Down
8 changes: 3 additions & 5 deletions lib/services/debug-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class DebugService extends EventEmitter implements IDebugService {
this.$errors.failWithoutHelp(`Unsupported device OS: ${device.deviceInfo.platform}. You can debug your applications only on iOS or Android.`);
}

if (this.$mobileHelper.isiOSPlatform(device.deviceInfo.platform)) {
if (this.$mobileHelper.isiOSPlatform(device.deviceInfo.platform)) { // TODO: Consider to move this code to ios-debug-service
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move the TODO above the code

if (device.isEmulator && !debugData.pathToAppPackage && debugOptions.debugBrk) {
this.$errors.failWithoutHelp("To debug on iOS simulator you need to provide path to the app package.");
}
Expand All @@ -61,12 +61,10 @@ export class DebugService extends EventEmitter implements IDebugService {
} else if (!this.$hostInfo.isDarwin) {
this.$errors.failWithoutHelp(`Debugging on iOS devices is not supported for ${platform()} yet.`);
}

result = await debugService.debug(debugData, debugOptions);
} else if (this.$mobileHelper.isAndroidPlatform(device.deviceInfo.platform)) {
result = await debugService.debug(debugData, debugOptions);
}

result = await debugService.debug(debugData, debugOptions);

return this.getDebugInformation(result, device.deviceInfo.identifier);
}

Expand Down
8 changes: 3 additions & 5 deletions lib/services/ios-debug-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ export class IOSDebugService extends DebugServiceBase implements IPlatformDebugS
await this.device.openDeviceLogStream();
}

this.$iOSDebuggerPortService.attachToDebuggerPortFoundEvent(this.device, debugData);

if (debugOptions.emulator) {
if (debugOptions.start) {
return this.emulatorStart(debugData, debugOptions);
Expand Down Expand Up @@ -142,12 +144,8 @@ export class IOSDebugService extends DebugServiceBase implements IPlatformDebugS
}

private async emulatorStart(debugData: IDebugData, debugOptions: IDebugOptions): Promise<string> {
const device = await this.$devicesService.getDevice(debugData.deviceIdentifier);
this.$iOSDebuggerPortService.attachToDebuggerPortFoundEvent(device, debugData);
const result = await this.wireDebuggerClient(debugData, debugOptions);

const attachRequestMessage = this.$iOSNotification.getAttachRequest(debugData.applicationIdentifier, debugData.deviceIdentifier);

const iOSEmulatorService = <Mobile.IiOSSimulatorService>this.$iOSEmulatorServices;
await iOSEmulatorService.postDarwinNotification(attachRequestMessage, debugData.deviceIdentifier);
return result;
Expand Down Expand Up @@ -192,7 +190,7 @@ export class IOSDebugService extends DebugServiceBase implements IPlatformDebugS
}

private async deviceStartCore(device: Mobile.IiOSDevice, debugData: IDebugData, debugOptions: IDebugOptions): Promise<string> {
this.$iOSDebuggerPortService.attachToDebuggerPortFoundEvent(device, debugData);

await this.$iOSSocketRequestExecutor.executeAttachRequest(device, AWAIT_NOTIFICATION_TIMEOUT_SECONDS, debugData.applicationIdentifier);
return this.wireDebuggerClient(debugData, debugOptions, device);
}
Expand Down
7 changes: 4 additions & 3 deletions lib/services/livesync/android-livesync-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ export class AndroidLiveSyncService extends PlatformLiveSyncServiceBase implemen
$devicePathProvider: IDevicePathProvider,
$fs: IFileSystem,
$logger: ILogger,
$projectFilesProvider: IProjectFilesProvider,
) {
super($fs, $logger, $platformsData, $projectFilesManager, $devicePathProvider, $projectFilesProvider);
$projectFilesProvider: IProjectFilesProvider) {
super($fs, $logger, $platformsData, $projectFilesManager, $devicePathProvider, $projectFilesProvider);
}

protected _getDeviceLiveSyncService(device: Mobile.IDevice, data: IProjectDir): INativeScriptDeviceLiveSyncService {
const service = this.$injector.resolve<INativeScriptDeviceLiveSyncService>(AndroidDeviceLiveSyncService, { _device: device, data });
return service;
}

public prepareForLiveSync(device: Mobile.IDevice, data: IProjectDir): void { /* */ }
}
$injector.register("androidLiveSyncService", AndroidLiveSyncService);
1 change: 0 additions & 1 deletion lib/services/livesync/ios-device-livesync-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export class IOSDeviceLiveSyncService extends DeviceLiveSyncServiceBase implemen
private $processService: IProcessService,
protected $platformsData: IPlatformsData) {
super($platformsData);
this.$iOSDebuggerPortService.attachToDebuggerPortFoundEvent(_device, data);
this.device = _device;
}

Expand Down
16 changes: 9 additions & 7 deletions lib/services/livesync/ios-livesync-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,16 @@ export class IOSLiveSyncService extends PlatformLiveSyncServiceBase implements I
$devicePathProvider: IDevicePathProvider,
$logger: ILogger,
$projectFilesProvider: IProjectFilesProvider,
private $iOSDebuggerPortService: IIOSDebuggerPortService,
) {
super($fs, $logger, $platformsData, $projectFilesManager, $devicePathProvider, $projectFilesProvider);
}
private $iOSDebuggerPortService: IIOSDebuggerPortService) {
super($fs, $logger, $platformsData, $projectFilesManager, $devicePathProvider, $projectFilesProvider);
}

public async fullSync(syncInfo: IFullSyncInfo): Promise<ILiveSyncResultInfo> {
const device = syncInfo.device;

if (device.isEmulator) {
return super.fullSync(syncInfo);
}

this.$iOSDebuggerPortService.attachToDebuggerPortFoundEvent(device, syncInfo.projectData);

const projectData = syncInfo.projectData;
const platformData = this.$platformsData.getPlatformData(device.deviceInfo.platform, projectData);
const deviceAppData = await this.getAppData(syncInfo);
Expand Down Expand Up @@ -70,6 +66,12 @@ export class IOSLiveSyncService extends PlatformLiveSyncServiceBase implements I
}
}

public prepareForLiveSync(device: Mobile.IDevice, data: IProjectDir, liveSyncInfo: ILiveSyncInfo): void {
if (!liveSyncInfo.skipWatcher) {
this.$iOSDebuggerPortService.attachToDebuggerPortFoundEvent(device, data);
}
}

protected _getDeviceLiveSyncService(device: Mobile.IDevice, data: IProjectDir): INativeScriptDeviceLiveSyncService {
const service = this.$injector.resolve<INativeScriptDeviceLiveSyncService>(IOSDeviceLiveSyncService, { _device: device, data });
return service;
Expand Down
5 changes: 4 additions & 1 deletion lib/services/livesync/livesync-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -456,8 +456,11 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
const deviceAction = async (device: Mobile.IDevice): Promise<void> => {
try {
const platform = device.deviceInfo.platform;
const liveSyncService = this.getLiveSyncService(platform);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be called const platformLiveSyncService

const deviceBuildInfoDescriptor = _.find(deviceDescriptors, dd => dd.identifier === device.deviceInfo.identifier);

liveSyncService.prepareForLiveSync(device, projectData, liveSyncData);

await this.ensureLatestAppPackageIsInstalledOnDevice({
device,
preparedPlatforms,
Expand All @@ -472,7 +475,7 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
env: liveSyncData.env
}, { skipNativePrepare: deviceBuildInfoDescriptor.skipNativePrepare });

const liveSyncResultInfo = await this.getLiveSyncService(platform).fullSync({
const liveSyncResultInfo = await liveSyncService.fullSync({
projectData, device,
syncAllFiles: liveSyncData.watchAllFiles,
useLiveEdit: liveSyncData.useLiveEdit,
Expand Down
1 change: 0 additions & 1 deletion lib/services/livesync/platform-livesync-service-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,5 +138,4 @@ export abstract class PlatformLiveSyncServiceBase {
action.call(this.$logger, util.format(message, "all files"));
}
}

}