Skip to content

Commit 15f0142

Browse files
author
Tsvetan Raikov
committed
Fixed: Livesync on Android is not working after changes in tns-core-modules
1 parent 63a70c8 commit 15f0142

11 files changed

+31
-8
lines changed

lib/commands/debug.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
let applicationReloadAction = (deviceAppData: Mobile.IDeviceAppData, localToDevicePaths: Mobile.ILocalToDevicePathData[]): IFuture<void> => {
1616
return (() => {
1717
let projectData: IProjectData = this.$injector.resolve("projectData");
18-
1918
this.debugService.debugStop().wait();
20-
21-
let applicationId = deviceAppData.device.isEmulator ? projectData.projectName : deviceAppData.appIdentifier;
19+
let applicationId = deviceAppData.appIdentifier;
20+
if (deviceAppData.device.isEmulator && deviceAppData.platform.toLowerCase() === this.$devicePlatformsConstants.iOS.toLocaleLowerCase()) {
21+
applicationId = projectData.projectName;
22+
}
2223
deviceAppData.device.applicationManager.stopApplication(applicationId).wait();
23-
2424
this.debugService.debug().wait();
2525
}).future<void>()();
2626
};

lib/definitions/platform.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ interface IPlatformService {
1515
deployOnEmulator(platform: string, buildConfig?: IBuildConfig): IFuture<void>;
1616
validatePlatformInstalled(platform: string): void;
1717
validatePlatform(platform: string): void;
18+
isPlatformBuilt(platform: string): IFuture<boolean>;
1819

1920
getLatestApplicationPackageForDevice(platformData: IPlatformData): IFuture<IApplicationPackage>;
2021
getLatestApplicationPackageForEmulator(platformData: IPlatformData): IFuture<IApplicationPackage>;

lib/definitions/project.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ interface IPlatformProjectService {
9494
* Ensures there is configuration file (AndroidManifest.xml, Info.plist) in app/App_Resources.
9595
*/
9696
ensureConfigurationFileInAppResources(): IFuture<void>;
97+
isPlatformBuilt(projectRoot: string): IFuture<boolean>;
9798
}
9899

99100
interface IAndroidProjectPropertiesManager {

lib/services/android-project-service.ts

+5
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,10 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
298298
return this.$fs.exists(path.join(this.platformData.appDestinationDirectoryPath, constants.APP_FOLDER_NAME));
299299
}
300300

301+
public isPlatformBuilt(projectRoot: string): IFuture<boolean> {
302+
return this.$fs.exists(path.join(projectRoot, "build", "outputs", "apk"));
303+
}
304+
301305
public getFrameworkFilesExtensions(): string[] {
302306
return [".jar", ".dat"];
303307
}
@@ -406,6 +410,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
406410

407411
public beforePrepareAllPlugins(): IFuture<void> {
408412
let buildOptions = this.getBuildOptions();
413+
409414
buildOptions.unshift("clean");
410415

411416
let projectRoot = this.platformData.projectRoot;

lib/services/ios-project-service.ts

+4
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,10 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
357357
return this.$fs.exists(path.join(projectRoot, this.$projectData.projectName, constants.APP_FOLDER_NAME));
358358
}
359359

360+
public isPlatformBuilt(projectRoot: string): IFuture<boolean> {
361+
return this.$fs.exists(path.join(projectRoot, "build"));
362+
}
363+
360364
public deploy(deviceIdentifier: string): IFuture<void> {
361365
return Future.fromResult();
362366
}

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ class AndroidPlatformLiveSyncService extends PlatformLiveSyncServiceBase {
1111
protected $injector: IInjector,
1212
protected $projectFilesManager: IProjectFilesManager,
1313
protected $projectFilesProvider: IProjectFilesProvider,
14+
protected $platformService: IPlatformService,
1415
protected $liveSyncProvider: ILiveSyncProvider) {
15-
super(_liveSyncData, $devicesService, $mobileHelper, $logger, $options, $deviceAppDataFactory, $fs, $injector, $projectFilesManager, $projectFilesProvider, $liveSyncProvider);
16+
super(_liveSyncData, $devicesService, $mobileHelper, $logger, $options, $deviceAppDataFactory, $fs, $injector, $projectFilesManager, $projectFilesProvider, $platformService, $liveSyncProvider);
1617
}
1718

1819
public fullSync(postAction?: (deviceAppData: Mobile.IDeviceAppData, localToDevicePaths: Mobile.ILocalToDevicePathData[]) => IFuture<void>): IFuture<void> {

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ class IOSPlatformLiveSyncService extends PlatformLiveSyncServiceBase {
1111
protected $injector: IInjector,
1212
protected $projectFilesManager: IProjectFilesManager,
1313
protected $projectFilesProvider: IProjectFilesProvider,
14+
protected $platformService: IPlatformService,
1415
protected $liveSyncProvider: ILiveSyncProvider) {
15-
super(_liveSyncData, $devicesService, $mobileHelper, $logger, $options, $deviceAppDataFactory, $fs, $injector, $projectFilesManager, $projectFilesProvider, $liveSyncProvider);
16+
super(_liveSyncData, $devicesService, $mobileHelper, $logger, $options, $deviceAppDataFactory, $fs, $injector, $projectFilesManager, $projectFilesProvider, $platformService, $liveSyncProvider);
1617
}
1718

1819
public fullSync(postAction?: (deviceAppData: Mobile.IDeviceAppData, localToDevicePaths: Mobile.ILocalToDevicePathData[]) => IFuture<void>): IFuture<void> {

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export abstract class PlatformLiveSyncServiceBase implements IPlatformLiveSyncSe
2424
protected $injector: IInjector,
2525
protected $projectFilesManager: IProjectFilesManager,
2626
protected $projectFilesProvider: IProjectFilesProvider,
27+
protected $platformService: IPlatformService,
2728
protected $liveSyncProvider: ILiveSyncProvider) {
2829
this.liveSyncData = _liveSyncData;
2930
this.fileHashes = Object.create(null);
@@ -78,7 +79,7 @@ export abstract class PlatformLiveSyncServiceBase implements IPlatformLiveSyncSe
7879
device.applicationManager.checkForApplicationUpdates().wait();
7980

8081
let appIdentifier = this.liveSyncData.appIdentifier;
81-
if (!device.applicationManager.isApplicationInstalled(appIdentifier).wait()) {
82+
if (!device.applicationManager.isApplicationInstalled(appIdentifier).wait() || !this.$platformService.isPlatformBuilt(deviceAppData.platform.toLowerCase()).wait()) {
8283
this.$logger.warn(`The application with id "${appIdentifier}" is not installed on device with identifier ${device.deviceInfo.identifier}.`);
8384

8485
let packageFilePath = this.$liveSyncProvider.buildForDevice(device).wait();

lib/services/platform-service.ts

+5
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,11 @@ export class PlatformService implements IPlatformService {
618618
return platformData.platformProjectService.isPlatformPrepared(platformData.projectRoot);
619619
}
620620

621+
public isPlatformBuilt(platform: string): IFuture<boolean> {
622+
let platformData = this.$platformsData.getPlatformData(platform);
623+
return platformData.platformProjectService.isPlatformBuilt(platformData.projectRoot);
624+
}
625+
621626
private getApplicationPackages(buildOutputPath: string, validPackageNames: string[]): IFuture<IApplicationPackage[]> {
622627
return (() => {
623628
// Get latest package that is produced from build

lib/tools/broccoli/node-modules-dest-copy.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export class DestCopy implements IBroccoliPlugin {
2424
private $fs: IFileSystem,
2525
private $projectFilesManager: IProjectFilesManager,
2626
private $pluginsService: IPluginsService,
27+
private $config: IConfiguration,
2728
private $platformsData: IPlatformsData
2829
) {
2930
this.dependencies = Object.create(null);
@@ -69,7 +70,7 @@ export class DestCopy implements IBroccoliPlugin {
6970
});
7071
}
7172
});
72-
if (!_.isEmpty(this.dependencies)) {
73+
if (!_.isEmpty(this.dependencies) && !this.$config.debugLivesync) {
7374
this.$platformsData.getPlatformData(platform).platformProjectService.beforePrepareAllPlugins().wait();
7475
}
7576

test/stubs.ts

+3
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,9 @@ export class PlatformProjectServiceStub implements IPlatformProjectService {
324324
isPlatformPrepared(projectRoot: string): IFuture<boolean> {
325325
return Future.fromResult(false);
326326
}
327+
isPlatformBuilt(projectRoot: string): IFuture<boolean> {
328+
return Future.fromResult(false);
329+
}
327330
canUpdatePlatform(currentVersion: string, newVersion: string): IFuture<boolean> {
328331
return Future.fromResult(false);
329332
}

0 commit comments

Comments
 (0)