Skip to content

Commit e136ac9

Browse files
committed
fix: fix native change during livesync on iOS device
We need to execute full sync after install on iOS device in order to create LiveSync folder on device.
1 parent 12e8f6a commit e136ac9

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

lib/controllers/run-controller.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ export class RunController extends EventEmitter implements IRunController {
352352
}
353353

354354
await this.$deviceInstallAppService.installOnDevice(device, deviceDescriptor.buildData, this.rebuiltInformation[platformData.platformNameLowerCase].packageFilePath);
355+
await platformLiveSyncService.syncAfterInstall(device, watchInfo);
355356
await platformLiveSyncService.restartApplication(projectData, { deviceAppData, modifiedFilesData: [], isFullSync: false, useHotModuleReload: liveSyncInfo.useHotModuleReload });
356357
} else {
357358
const isInHMRMode = liveSyncInfo.useHotModuleReload && data.hmrData && data.hmrData.hash;

lib/definitions/livesync.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ declare global {
251251
shouldRestart(projectData: IProjectData, liveSyncInfo: ILiveSyncResultInfo): Promise<boolean>;
252252
getDeviceLiveSyncService(device: Mobile.IDevice, projectData: IProjectData): INativeScriptDeviceLiveSyncService;
253253
getAppData(syncInfo: IFullSyncInfo): Promise<Mobile.IDeviceAppData>;
254+
syncAfterInstall(device: Mobile.IDevice, liveSyncInfo: ILiveSyncWatchInfo): Promise<void>;
254255
}
255256

256257
interface IRestartApplicationInfo {

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,16 @@ export class IOSLiveSyncService extends PlatformLiveSyncServiceBase implements I
5555
};
5656
}
5757

58-
@performanceLog()
59-
public liveSyncWatchAction(device: Mobile.IDevice, liveSyncInfo: ILiveSyncWatchInfo): Promise<ILiveSyncResultInfo> {
60-
if (liveSyncInfo.isReinstalled) {
58+
public async syncAfterInstall(device: Mobile.IDevice, liveSyncInfo: ILiveSyncWatchInfo): Promise<void> {
59+
if (!device.isEmulator) {
6160
// In this case we should execute fullsync because iOS Runtime requires the full content of app dir to be extracted in the root of sync dir.
62-
return this.fullSync({
61+
await this.fullSync({
6362
projectData: liveSyncInfo.projectData,
6463
device,
6564
liveSyncDeviceData: liveSyncInfo.liveSyncDeviceData,
6665
watch: true,
6766
useHotModuleReload: liveSyncInfo.useHotModuleReload
6867
});
69-
} else {
70-
return super.liveSyncWatchAction(device, liveSyncInfo);
7168
}
7269
}
7370

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as path from "path";
22
import * as util from "util";
33
import { APP_FOLDER_NAME } from "../../constants";
44
import { getHash } from "../../common/helpers";
5+
import { performanceLog } from "../../common/decorators";
56

67
export abstract class PlatformLiveSyncServiceBase {
78
private _deviceLiveSyncServicesCache: IDictionary<INativeScriptDeviceLiveSyncService> = {};
@@ -32,6 +33,8 @@ export abstract class PlatformLiveSyncServiceBase {
3233
return shouldRestart;
3334
}
3435

36+
public async syncAfterInstall(device: Mobile.IDevice, liveSyncInfo: ILiveSyncWatchInfo): Promise<void> { /* intentionally left blank */ }
37+
3538
public async restartApplication(projectData: IProjectData, liveSyncInfo: ILiveSyncResultInfo): Promise<void> {
3639
const deviceLiveSyncService = this.getDeviceLiveSyncService(liveSyncInfo.deviceAppData.device, projectData);
3740
this.$logger.info(`Restarting application on device ${liveSyncInfo.deviceAppData.device.deviceInfo.identifier}...`);
@@ -72,6 +75,7 @@ export abstract class PlatformLiveSyncServiceBase {
7275
};
7376
}
7477

78+
@performanceLog()
7579
public async liveSyncWatchAction(device: Mobile.IDevice, liveSyncInfo: ILiveSyncWatchInfo): Promise<ILiveSyncResultInfo> {
7680
const projectData = liveSyncInfo.projectData;
7781
const deviceLiveSyncService = this.getDeviceLiveSyncService(device, projectData);

0 commit comments

Comments
 (0)