Skip to content

Commit 1032a7b

Browse files
Fatme HavaluovaFatme Havaluova
authored andcommitted
Fix crash when launching applications on iOS device in debug mode
Fixes #1362
1 parent 98a96fb commit 1032a7b

File tree

5 files changed

+53
-4
lines changed

5 files changed

+53
-4
lines changed

lib/definitions/project.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ interface IPlatformProjectServiceBase {
4949
interface IBuildConfig {
5050
runSbGenerator?: boolean;
5151
buildForDevice?: boolean;
52+
architectures?: string[];
5253
}
5354

5455
interface IPlatformProjectService {
@@ -59,6 +60,7 @@ interface IPlatformProjectService {
5960
interpolateConfigurationFile(configurationFilePath?: string): IFuture<void>;
6061
afterCreateProject(projectRoot: string): IFuture<void>;
6162
buildProject(projectRoot: string, buildConfig?: IBuildConfig): IFuture<void>;
63+
buildForDeploy(projectRoot: string, buildConfig?: IBuildConfig): IFuture<void>;
6264
prepareProject(): IFuture<void>;
6365
prepareAppResources(appResourcesDirectoryPath: string): IFuture<void>;
6466
isPlatformPrepared(projectRoot: string): IFuture<boolean>;

lib/services/android-project-service.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,10 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
238238
}).future<void>()();
239239
}
240240

241+
public buildForDeploy(projectRoot: string, buildConfig?: IBuildConfig): IFuture<void> {
242+
return this.buildProject(projectRoot, buildConfig);
243+
}
244+
241245
public isPlatformPrepared(projectRoot: string): IFuture<boolean> {
242246
return this.$fs.exists(path.join(this.platformData.appDestinationDirectoryPath, constants.APP_FOLDER_NAME));
243247
}

lib/services/ios-project-service.ts

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
3535
$projectDataService: IProjectDataService,
3636
private $prompter: IPrompter,
3737
private $config: IConfiguration,
38-
private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants) {
38+
private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
39+
private $devicesService: Mobile.IDevicesService,
40+
private $mobileHelper: Mobile.IMobileHelper) {
3941
super($fs, $projectData, $projectDataService);
4042
}
4143

@@ -177,12 +179,17 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
177179
let args: string[] = [];
178180
let buildForDevice = this.$options.forDevice || (buildConfig && buildConfig.buildForDevice);
179181
if (buildForDevice) {
182+
let defaultArchitectures = [
183+
'ARCHS=armv7 arm64',
184+
'VALID_ARCHS=armv7 arm64'
185+
];
186+
180187
args = basicArgs.concat([
181188
"-sdk", "iphoneos",
182-
'ARCHS=armv7 arm64',
183-
'VALID_ARCHS=armv7 arm64',
184189
"CONFIGURATION_BUILD_DIR=" + path.join(projectRoot, "build", "device")
185190
]);
191+
192+
args = args.concat((buildConfig && buildConfig.architectures) || defaultArchitectures);
186193
} else {
187194
args = basicArgs.concat([
188195
"-sdk", "iphonesimulator",
@@ -210,6 +217,29 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
210217
}).future<void>()();
211218
}
212219

220+
public buildForDeploy(platform: string): IFuture<void> {
221+
if (this.$options.release) {
222+
return this.buildProject(this.platformData.projectRoot);
223+
}
224+
225+
let devicesArchitectures = _(this.$devicesService.getDeviceInstances())
226+
.filter(d => this.$mobileHelper.isiOSPlatform(d.deviceInfo.platform))
227+
.map(d => d.deviceInfo.activeArchitecture)
228+
.uniq()
229+
.value();
230+
231+
let architectures = [
232+
`ARCHS=${devicesArchitectures.join(" ")}`,
233+
`VALID_ARCHS=${devicesArchitectures.join(" ")}`
234+
];
235+
236+
if (devicesArchitectures.length > 1) {
237+
architectures.push('ONLY_ACTIVE_ARCH=NO');
238+
}
239+
240+
return this.buildProject(this.platformData.projectRoot, { architectures: architectures });
241+
}
242+
213243
public isPlatformPrepared(projectRoot: string): IFuture<boolean> {
214244
return this.$fs.exists(path.join(projectRoot, this.$projectData.projectName, constants.APP_FOLDER_NAME));
215245
}

lib/services/platform-service.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,19 @@ export class PlatformService implements IPlatformService {
306306
}).future<void>()();
307307
}
308308

309+
public buildForDeploy(platform: string, buildConfig?: IBuildConfig): IFuture<string> {
310+
return (() => {
311+
platform = platform.toLowerCase();
312+
if (!this.preparePlatform(platform).wait()) {
313+
this.$errors.failWithoutHelp("Verify that listed files are well-formed and try again the operation.");
314+
}
315+
316+
let platformData = this.$platformsData.getPlatformData(platform);
317+
platformData.platformProjectService.buildForDeploy(platformData.projectRoot, buildConfig).wait();
318+
this.$logger.out("Project successfully built");
319+
}).future<string>()();
320+
}
321+
309322
public copyLastOutput(platform: string, targetPath: string, settings: {isForDevice: boolean}): IFuture<void> {
310323
return (() => {
311324
let packageFile: string;

0 commit comments

Comments
 (0)