Skip to content

Commit 36ad3fe

Browse files
Fix destination in buildProject (#2706)
* Fix destination in buildProject Fix: Fix destination in buildProject when running with device arg but no specific UDID or args.destination * Fix: Add missing device build flag * Fix: Remove migrated device build flag * Fix: JS copy-paste * Update buildProject.ts Review comment * Update buildProject.ts newline * Update buildProject.ts space * Update buildProject.ts fix lint * Update getBuildSettings.ts fix lint * Update getBuildSettings.ts fix lint
1 parent 9147b97 commit 36ad3fe

File tree

4 files changed

+23
-16
lines changed

4 files changed

+23
-16
lines changed

packages/cli-platform-apple/src/commands/buildCommand/buildOptions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export type BuildFlags = {
1313
extraParams?: string[];
1414
forcePods?: boolean;
1515
onlyPods?: boolean;
16+
device?: string | true;
1617
};
1718

1819
export const getBuildOptions = ({platformName}: BuilderCommand) => {

packages/cli-platform-apple/src/commands/buildCommand/buildProject.ts

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,22 @@ export function buildProject(
5252
return;
5353
}
5454

55+
const isDevice = args.device;
56+
let destination = '';
57+
if (udid) {
58+
destination = `id=${udid}`;
59+
} else if (isDevice) {
60+
destination = 'generic/platform=iOS';
61+
} else if (mode === 'Debug') {
62+
destination = `generic/platform=${simulatorDest}`;
63+
} else {
64+
destination = `generic/platform=${platform}`;
65+
}
66+
67+
if (args.destination) {
68+
destination += `,${args.destination}`;
69+
}
70+
5571
const xcodebuildArgs = [
5672
xcodeProject.isWorkspace ? '-workspace' : '-project',
5773
xcodeProject.name,
@@ -62,12 +78,7 @@ export function buildProject(
6278
'-scheme',
6379
scheme,
6480
'-destination',
65-
(udid
66-
? `id=${udid}`
67-
: mode === 'Debug'
68-
? `generic/platform=${simulatorDest}`
69-
: `generic/platform=${platform}`) +
70-
(args.destination ? ',' + args.destination : ''),
81+
destination,
7182
];
7283

7384
if (args.extraParams) {

packages/cli-platform-apple/src/commands/runCommand/createRun.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ import openApp from './openApp';
3939

4040
export interface FlagsT extends BuildFlags {
4141
simulator?: string;
42-
device?: string | true;
4342
udid?: string;
4443
binaryPath?: string;
4544
listDevices?: boolean;

packages/cli-platform-apple/src/commands/runCommand/getBuildSettings.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,13 @@ export async function getBuildSettings(
3838

3939
// Find all 'app' targets in the build settings
4040
const applicationTargets = settings
41-
.filter(
42-
(setting: any) =>
43-
setting.buildSettings.WRAPPER_EXTENSION ===
44-
'app',
45-
)
41+
.filter((setting: any) => setting.buildSettings.WRAPPER_EXTENSION === 'app')
4642
.map(({target: settingsTarget}: any) => settingsTarget);
4743

48-
if (applicationTargets.length === 0) return null
49-
44+
if (applicationTargets.length === 0) return null;
45+
5046
let selectedTarget = applicationTargets[0];
51-
47+
5248
if (target) {
5349
if (!applicationTargets.includes(target)) {
5450
logger.info(
@@ -60,7 +56,7 @@ export async function getBuildSettings(
6056
selectedTarget = target;
6157
}
6258
}
63-
59+
6460
const targetIndex = applicationTargets.indexOf(selectedTarget);
6561
return settings[targetIndex].buildSettings;
6662
}

0 commit comments

Comments
 (0)