Skip to content

Commit d9241f8

Browse files
author
Fatme
authored
Merge pull request #4738 from NativeScript/vladimirov/fix-provision
fix: enable passing iOS codesigning options to LiveSync operations
2 parents b1047af + 53641b8 commit d9241f8

File tree

7 files changed

+42
-21
lines changed

7 files changed

+42
-21
lines changed

lib/controllers/debug-controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export class DebugController extends EventEmitter implements IDebugController {
128128
const attachDebuggerData: IAttachDebuggerData = {
129129
deviceIdentifier,
130130
isEmulator: currentDeviceInstance.isEmulator,
131-
outputPath: deviceDescriptor.outputPath,
131+
outputPath: deviceDescriptor.buildData.outputPath,
132132
platform: currentDeviceInstance.deviceInfo.platform,
133133
projectDir,
134134
debugOptions

lib/controllers/run-controller.ts

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ import { cache, performanceLog } from "../common/decorators";
44
import { EventEmitter } from "events";
55

66
export class RunController extends EventEmitter implements IRunController {
7-
private rebuiltInformation: IDictionary<any> = {};
7+
private rebuiltInformation: IDictionary<{ packageFilePath: string, platform: string, isEmulator: boolean }> = { };
88

99
constructor(
1010
protected $analyticsService: IAnalyticsService,
11-
private $buildDataService: IBuildDataService,
1211
private $buildController: IBuildController,
1312
private $debugController: IDebugController,
1413
private $deviceInstallAppService: IDeviceInstallAppService,
@@ -191,7 +190,7 @@ export class RunController extends EventEmitter implements IRunController {
191190
projectDir: projectData.projectDir,
192191
deviceIdentifier,
193192
debugOptions: deviceDescriptor.debugOptions,
194-
outputPath: deviceDescriptor.outputPath
193+
outputPath: deviceDescriptor.buildData.outputPath
195194
};
196195
this.emit(USER_INTERACTION_NEEDED_EVENT_NAME, attachDebuggerOptions);
197196
}
@@ -242,9 +241,16 @@ export class RunController extends EventEmitter implements IRunController {
242241
const deviceAction = async (device: Mobile.IDevice) => {
243242
const deviceDescriptor = _.find(deviceDescriptors, dd => dd.identifier === device.deviceInfo.identifier);
244243
const platformData = this.$platformsDataService.getPlatformData(device.deviceInfo.platform, projectData);
245-
const prepareData = this.$prepareDataService.getPrepareData(liveSyncInfo.projectDir, device.deviceInfo.platform, { ...liveSyncInfo, watch: !liveSyncInfo.skipWatcher, nativePrepare: { skipNativePrepare: !!deviceDescriptor.skipNativePrepare } });
246-
const buildData = this.$buildDataService.getBuildData(projectData.projectDir, device.deviceInfo.platform, { ...liveSyncInfo, outputPath: deviceDescriptor.outputPath, buildForDevice: !device.isEmulator });
244+
const prepareData = this.$prepareDataService.getPrepareData(liveSyncInfo.projectDir, device.deviceInfo.platform,
245+
{
246+
...liveSyncInfo,
247+
...deviceDescriptor.buildData,
248+
nativePrepare: { skipNativePrepare: !!deviceDescriptor.skipNativePrepare },
249+
watch: !liveSyncInfo.skipWatcher,
250+
});
251+
247252
const prepareResultData = await this.$prepareController.prepare(prepareData);
253+
const buildData = { ...deviceDescriptor.buildData, buildForDevice: !device.isEmulator };
248254

249255
try {
250256
let packageFilePath: string = null;
@@ -312,14 +318,24 @@ export class RunController extends EventEmitter implements IRunController {
312318
const deviceAction = async (device: Mobile.IDevice) => {
313319
const deviceDescriptor = _.find(deviceDescriptors, dd => dd.identifier === device.deviceInfo.identifier);
314320
const platformData = this.$platformsDataService.getPlatformData(data.platform, projectData);
315-
const prepareData = this.$prepareDataService.getPrepareData(projectData.projectDir, data.platform, { ...liveSyncInfo, watch: !liveSyncInfo.skipWatcher });
321+
const prepareData = this.$prepareDataService.getPrepareData(liveSyncInfo.projectDir, device.deviceInfo.platform,
322+
{
323+
...liveSyncInfo,
324+
...deviceDescriptor.buildData,
325+
nativePrepare: { skipNativePrepare: !!deviceDescriptor.skipNativePrepare },
326+
watch: !liveSyncInfo.skipWatcher,
327+
});
316328

317329
try {
318-
const rebuiltInfo = this.rebuiltInformation[platformData.platformNameLowerCase] && (this.$mobileHelper.isAndroidPlatform(platformData.platformNameLowerCase) || this.rebuiltInformation[platformData.platformNameLowerCase].isEmulator === device.isEmulator);
319-
if (data.hasNativeChanges && !rebuiltInfo) {
320-
await this.$prepareNativePlatformService.prepareNativePlatform(platformData, projectData, prepareData);
321-
await deviceDescriptor.buildAction();
322-
this.rebuiltInformation[platformData.platformNameLowerCase] = { isEmulator: device.isEmulator, platform: platformData.platformNameLowerCase, packageFilePath: null };
330+
if (data.hasNativeChanges) {
331+
const rebuiltInfo = this.rebuiltInformation[platformData.platformNameLowerCase] && (this.$mobileHelper.isAndroidPlatform(platformData.platformNameLowerCase) || this.rebuiltInformation[platformData.platformNameLowerCase].isEmulator === device.isEmulator);
332+
if (!rebuiltInfo) {
333+
await this.$prepareNativePlatformService.prepareNativePlatform(platformData, projectData, prepareData);
334+
await deviceDescriptor.buildAction();
335+
this.rebuiltInformation[platformData.platformNameLowerCase] = { isEmulator: device.isEmulator, platform: platformData.platformNameLowerCase, packageFilePath: null };
336+
}
337+
338+
await this.$deviceInstallAppService.installOnDevice(device, deviceDescriptor.buildData, this.rebuiltInformation[platformData.platformNameLowerCase].packageFilePath);
323339
}
324340

325341
const isInHMRMode = liveSyncInfo.useHotModuleReload && data.hmrData && data.hmrData.hash;

lib/definitions/livesync.d.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ declare global {
4848
/**
4949
* Describes information for LiveSync on a device.
5050
*/
51-
interface ILiveSyncDeviceDescriptor extends IOptionalOutputPath, IOptionalDebuggingOptions {
51+
interface ILiveSyncDeviceDescriptor extends IOptionalDebuggingOptions {
5252
/**
5353
* Device identifier.
5454
*/
@@ -68,6 +68,11 @@ declare global {
6868
* Whether debugging has been enabled for this device or not
6969
*/
7070
debuggingEnabled?: boolean;
71+
72+
/**
73+
* Describes the data used for building the application
74+
*/
75+
buildData: IBuildData;
7176
}
7277

7378
/**
@@ -80,7 +85,7 @@ declare global {
8085
* Defines if the watcher should be skipped. If not passed, fs.Watcher will be started.
8186
*/
8287
skipWatcher?: boolean;
83-
88+
8489
/**
8590
* Forces a build before the initial livesync.
8691
*/

lib/definitions/prepare.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ declare global {
99
watch?: boolean;
1010
}
1111

12-
interface IiOSPrepareData extends IPrepareData {
12+
interface IiOSCodeSigningData {
1313
teamId: string;
1414
provision: string;
1515
mobileProvisionData: any;
1616
}
1717

18-
interface IAndroidPrepareData extends IPrepareData { }
18+
interface IiOSPrepareData extends IPrepareData, IiOSCodeSigningData { }
1919

2020
interface IPrepareDataService {
2121
getPrepareData(projectDir: string, platform: string, data: any): IPrepareData;
@@ -34,4 +34,4 @@ declare global {
3434
interface IPrepareNativePlatformService {
3535
prepareNativePlatform(platformData: IPlatformData, projectData: IProjectData, prepareData: IPrepareData): Promise<boolean>;
3636
}
37-
}
37+
}

lib/helpers/deploy-command-helper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ export class DeployCommandHelper {
4343
buildAction,
4444
debuggingEnabled: additionalOptions && additionalOptions.deviceDebugMap && additionalOptions.deviceDebugMap[d.deviceInfo.identifier],
4545
debugOptions: this.$options,
46-
outputPath,
4746
skipNativePrepare: additionalOptions && additionalOptions.skipNativePrepare,
47+
buildData
4848
};
4949

5050
return info;

lib/helpers/livesync-command-helper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ export class LiveSyncCommandHelper implements ILiveSyncCommandHelper {
7979
buildAction,
8080
debuggingEnabled: additionalOptions && additionalOptions.deviceDebugMap && additionalOptions.deviceDebugMap[d.deviceInfo.identifier],
8181
debugOptions: this.$options,
82-
outputPath,
8382
skipNativePrepare: additionalOptions && additionalOptions.skipNativePrepare,
83+
buildData
8484
};
8585

8686
return info;

test/controllers/run-controller.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ const projectDir = "/path/to/my/projecDir";
1818
const buildOutputPath = `${projectDir}/platform/ios/build/myproject.app`;
1919

2020
const iOSDevice = <any>{ deviceInfo: { identifier: "myiOSDevice", platform: "ios" } };
21-
const iOSDeviceDescriptor = { identifier: "myiOSDevice", buildAction: async () => buildOutputPath };
21+
const iOSDeviceDescriptor = { identifier: "myiOSDevice", buildAction: async () => buildOutputPath, buildData: <any>{} };
2222
const androidDevice = <any>{ deviceInfo: { identifier: "myAndroidDevice", platform: "android" } };
23-
const androidDeviceDescriptor = { identifier: "myAndroidDevice", buildAction: async () => buildOutputPath };
23+
const androidDeviceDescriptor = { identifier: "myAndroidDevice", buildAction: async () => buildOutputPath, buildData: <any>{} };
2424

2525
const map: IDictionary<{ device: Mobile.IDevice, descriptor: ILiveSyncDeviceDescriptor }> = {
2626
myiOSDevice: {

0 commit comments

Comments
 (0)