Skip to content

Commit d9c57c2

Browse files
Fix destination in buildProject
Fix: Fix destination in buildProject when running with device arg but no specific UDID or args.destination
1 parent 26dd51a commit d9c57c2

1 file changed

Lines changed: 30 additions & 17 deletions

File tree

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

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,35 @@ export function buildProject(
3939
args: BuildFlags,
4040
): Promise<string> {
4141
return new Promise((resolve, reject) => {
42-
const simulatorDest = simulatorDestinationMap?.[platform];
43-
44-
if (!simulatorDest) {
45-
reject(
46-
new CLIError(
47-
`Unknown platform: ${platform}. Please, use one of: ${Object.values(
48-
supportedPlatforms,
49-
).join(', ')}.`,
50-
),
51-
);
52-
return;
42+
const isDevice = args.device;
43+
let destination = '';
44+
if (udid) {
45+
destination = `id=${udid}`;
46+
} else if (isDevice) {
47+
destination = 'generic/platform=iOS';
48+
} else if (mode === 'Debug') {
49+
const simulatorDest =
50+
simulatorDestinationMap.simulatorDestinationMap === null ||
51+
simulatorDestinationMap.simulatorDestinationMap === void 0
52+
? void 0
53+
: simulatorDestinationMap.simulatorDestinationMap[platform];
54+
if (!simulatorDest) {
55+
reject(
56+
new CLIError(
57+
`Unknown platform: ${platform}. Please, use one of: ${Object.values(
58+
supportedPlatforms,
59+
).join(', ')}.`,
60+
),
61+
);
62+
return;
63+
}
64+
destination = `generic/platform=${simulatorDest}`;
65+
} else {
66+
destination = `generic/platform=${platform}`;
67+
}
68+
69+
if (args.destination) {
70+
destination += `,${args.destination}`;
5371
}
5472

5573
const xcodebuildArgs = [
@@ -62,12 +80,7 @@ export function buildProject(
6280
'-scheme',
6381
scheme,
6482
'-destination',
65-
(udid
66-
? `id=${udid}`
67-
: mode === 'Debug'
68-
? `generic/platform=${simulatorDest}`
69-
: `generic/platform=${platform}`) +
70-
(args.destination ? ',' + args.destination : ''),
83+
destination,
7184
];
7285

7386
if (args.extraParams) {

0 commit comments

Comments
 (0)