Skip to content

Commit d112c1a

Browse files
Merge pull request #3657 from NativeScript/fatme/fix-justlaunch
Fix `tns run ios --justlaunch`
2 parents 8a6e7a3 + 2cb0dc3 commit d112c1a

8 files changed

+24
-22
lines changed

lib/definitions/livesync.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ interface IPlatformLiveSyncService {
337337
fullSync(syncInfo: IFullSyncInfo): Promise<ILiveSyncResultInfo>;
338338
liveSyncWatchAction(device: Mobile.IDevice, liveSyncInfo: ILiveSyncWatchInfo): Promise<ILiveSyncResultInfo>;
339339
refreshApplication(projectData: IProjectData, liveSyncInfo: ILiveSyncResultInfo): Promise<void>;
340+
prepareForLiveSync(device: Mobile.IDevice, data: IProjectDir, liveSyncInfo: ILiveSyncInfo): void;
340341
}
341342

342343
interface INativeScriptDeviceLiveSyncService extends IDeviceLiveSyncServiceBase {

lib/services/debug-service.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export class DebugService extends EventEmitter implements IDebugService {
5151
this.$errors.failWithoutHelp(`Unsupported device OS: ${device.deviceInfo.platform}. You can debug your applications only on iOS or Android.`);
5252
}
5353

54+
// TODO: Consider to move this code to ios-debug-service
5455
if (this.$mobileHelper.isiOSPlatform(device.deviceInfo.platform)) {
5556
if (device.isEmulator && !debugData.pathToAppPackage && debugOptions.debugBrk) {
5657
this.$errors.failWithoutHelp("To debug on iOS simulator you need to provide path to the app package.");
@@ -61,12 +62,10 @@ export class DebugService extends EventEmitter implements IDebugService {
6162
} else if (!this.$hostInfo.isDarwin) {
6263
this.$errors.failWithoutHelp(`Debugging on iOS devices is not supported for ${platform()} yet.`);
6364
}
64-
65-
result = await debugService.debug(debugData, debugOptions);
66-
} else if (this.$mobileHelper.isAndroidPlatform(device.deviceInfo.platform)) {
67-
result = await debugService.debug(debugData, debugOptions);
6865
}
6966

67+
result = await debugService.debug(debugData, debugOptions);
68+
7069
return this.getDebugInformation(result, device.deviceInfo.identifier);
7170
}
7271

lib/services/ios-debug-service.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ export class IOSDebugService extends DebugServiceBase implements IPlatformDebugS
6363
await this.device.openDeviceLogStream();
6464
}
6565

66+
this.$iOSDebuggerPortService.attachToDebuggerPortFoundEvent(this.device, debugData);
67+
6668
if (debugOptions.emulator) {
6769
if (debugOptions.start) {
6870
return this.emulatorStart(debugData, debugOptions);
@@ -142,12 +144,8 @@ export class IOSDebugService extends DebugServiceBase implements IPlatformDebugS
142144
}
143145

144146
private async emulatorStart(debugData: IDebugData, debugOptions: IDebugOptions): Promise<string> {
145-
const device = await this.$devicesService.getDevice(debugData.deviceIdentifier);
146-
this.$iOSDebuggerPortService.attachToDebuggerPortFoundEvent(device, debugData);
147147
const result = await this.wireDebuggerClient(debugData, debugOptions);
148-
149148
const attachRequestMessage = this.$iOSNotification.getAttachRequest(debugData.applicationIdentifier, debugData.deviceIdentifier);
150-
151149
const iOSEmulatorService = <Mobile.IiOSSimulatorService>this.$iOSEmulatorServices;
152150
await iOSEmulatorService.postDarwinNotification(attachRequestMessage, debugData.deviceIdentifier);
153151
return result;
@@ -192,7 +190,7 @@ export class IOSDebugService extends DebugServiceBase implements IPlatformDebugS
192190
}
193191

194192
private async deviceStartCore(device: Mobile.IiOSDevice, debugData: IDebugData, debugOptions: IDebugOptions): Promise<string> {
195-
this.$iOSDebuggerPortService.attachToDebuggerPortFoundEvent(device, debugData);
193+
196194
await this.$iOSSocketRequestExecutor.executeAttachRequest(device, AWAIT_NOTIFICATION_TIMEOUT_SECONDS, debugData.applicationIdentifier);
197195
return this.wireDebuggerClient(debugData, debugOptions, device);
198196
}

lib/services/livesync/android-livesync-service.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@ export class AndroidLiveSyncService extends PlatformLiveSyncServiceBase implemen
88
$devicePathProvider: IDevicePathProvider,
99
$fs: IFileSystem,
1010
$logger: ILogger,
11-
$projectFilesProvider: IProjectFilesProvider,
12-
) {
13-
super($fs, $logger, $platformsData, $projectFilesManager, $devicePathProvider, $projectFilesProvider);
11+
$projectFilesProvider: IProjectFilesProvider) {
12+
super($fs, $logger, $platformsData, $projectFilesManager, $devicePathProvider, $projectFilesProvider);
1413
}
1514

1615
protected _getDeviceLiveSyncService(device: Mobile.IDevice, data: IProjectDir): INativeScriptDeviceLiveSyncService {
1716
const service = this.$injector.resolve<INativeScriptDeviceLiveSyncService>(AndroidDeviceLiveSyncService, { _device: device, data });
1817
return service;
1918
}
19+
20+
public prepareForLiveSync(device: Mobile.IDevice, data: IProjectDir): void { /* */ }
2021
}
2122
$injector.register("androidLiveSyncService", AndroidLiveSyncService);

lib/services/livesync/ios-device-livesync-service.ts

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export class IOSDeviceLiveSyncService extends DeviceLiveSyncServiceBase implemen
2020
private $processService: IProcessService,
2121
protected $platformsData: IPlatformsData) {
2222
super($platformsData);
23-
this.$iOSDebuggerPortService.attachToDebuggerPortFoundEvent(_device, data);
2423
this.device = _device;
2524
}
2625

lib/services/livesync/ios-livesync-service.ts

+9-7
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,16 @@ export class IOSLiveSyncService extends PlatformLiveSyncServiceBase implements I
1313
$devicePathProvider: IDevicePathProvider,
1414
$logger: ILogger,
1515
$projectFilesProvider: IProjectFilesProvider,
16-
private $iOSDebuggerPortService: IIOSDebuggerPortService,
17-
) {
18-
super($fs, $logger, $platformsData, $projectFilesManager, $devicePathProvider, $projectFilesProvider);
19-
}
16+
private $iOSDebuggerPortService: IIOSDebuggerPortService) {
17+
super($fs, $logger, $platformsData, $projectFilesManager, $devicePathProvider, $projectFilesProvider);
18+
}
2019

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

2423
if (device.isEmulator) {
2524
return super.fullSync(syncInfo);
2625
}
27-
28-
this.$iOSDebuggerPortService.attachToDebuggerPortFoundEvent(device, syncInfo.projectData);
29-
3026
const projectData = syncInfo.projectData;
3127
const platformData = this.$platformsData.getPlatformData(device.deviceInfo.platform, projectData);
3228
const deviceAppData = await this.getAppData(syncInfo);
@@ -70,6 +66,12 @@ export class IOSLiveSyncService extends PlatformLiveSyncServiceBase implements I
7066
}
7167
}
7268

69+
public prepareForLiveSync(device: Mobile.IDevice, data: IProjectDir, liveSyncInfo: ILiveSyncInfo): void {
70+
if (!liveSyncInfo.skipWatcher) {
71+
this.$iOSDebuggerPortService.attachToDebuggerPortFoundEvent(device, data);
72+
}
73+
}
74+
7375
protected _getDeviceLiveSyncService(device: Mobile.IDevice, data: IProjectDir): INativeScriptDeviceLiveSyncService {
7476
const service = this.$injector.resolve<INativeScriptDeviceLiveSyncService>(IOSDeviceLiveSyncService, { _device: device, data });
7577
return service;

lib/services/livesync/livesync-service.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -456,8 +456,11 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
456456
const deviceAction = async (device: Mobile.IDevice): Promise<void> => {
457457
try {
458458
const platform = device.deviceInfo.platform;
459+
const platformLiveSyncService = this.getLiveSyncService(platform);
459460
const deviceBuildInfoDescriptor = _.find(deviceDescriptors, dd => dd.identifier === device.deviceInfo.identifier);
460461

462+
platformLiveSyncService.prepareForLiveSync(device, projectData, liveSyncData);
463+
461464
await this.ensureLatestAppPackageIsInstalledOnDevice({
462465
device,
463466
preparedPlatforms,
@@ -472,7 +475,7 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
472475
env: liveSyncData.env
473476
}, { skipNativePrepare: deviceBuildInfoDescriptor.skipNativePrepare });
474477

475-
const liveSyncResultInfo = await this.getLiveSyncService(platform).fullSync({
478+
const liveSyncResultInfo = await platformLiveSyncService.fullSync({
476479
projectData, device,
477480
syncAllFiles: liveSyncData.watchAllFiles,
478481
useLiveEdit: liveSyncData.useLiveEdit,

lib/services/livesync/platform-livesync-service-base.ts

-1
Original file line numberDiff line numberDiff line change
@@ -138,5 +138,4 @@ export abstract class PlatformLiveSyncServiceBase {
138138
action.call(this.$logger, util.format(message, "all files"));
139139
}
140140
}
141-
142141
}

0 commit comments

Comments
 (0)