Skip to content

Commit 403dd71

Browse files
authored
feat(ios): replace --destination with --destinations (#165)
* feat(ios): replace --destination with --destinations * changeset
1 parent 89891a6 commit 403dd71

File tree

4 files changed

+49
-26
lines changed

4 files changed

+49
-26
lines changed

.changeset/smart-humans-hunt.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@rnef/plugin-platform-apple': patch
3+
---
4+
5+
feat(ios): replace --destination with --destinations

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ npx create-rnef-app enterprise
120120

121121
- `--mode` to `--variant` for Android commands
122122
- `--mode` to `--configuration` for iOS commands
123-
- `--buildFolder` to `-build-folder` for iOS commands
123+
- `--buildFolder` to `--build-folder` for iOS commands
124+
- `--destination` to `--destinations` for iOS commands
124125
- `--appId` to `--app-id` for Android commands
125126
- `--appIdSuffix` to `--app-id-suffix` for Android commands
126127

packages/plugin-platform-apple/src/lib/commands/build/buildOptions.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export type BuildFlags = {
1313
device?: string;
1414
catalyst?: boolean;
1515
buildFolder?: string;
16-
destination?: string;
16+
destinations?: string[];
1717
archive?: boolean;
1818
};
1919

@@ -71,8 +71,10 @@ export const getBuildOptions = ({ platformName }: BuilderCommand) => {
7171
value: 'build',
7272
},
7373
{
74-
name: '--destination <string>',
75-
description: 'Explicitly extend destination e.g. "arch=x86_64"',
74+
name: '--destinations <list>',
75+
description:
76+
'Explicitly defined destinations e.g. "arch=x86_64". You can also pass a comma separated array e.g. "generic/platform=iphoneos,generic/platform=iphonesimulator"',
77+
parse: (val: string) => val.split(','),
7678
},
7779
{
7880
name: '--archive',

packages/plugin-platform-apple/src/lib/commands/build/buildProject.ts

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,42 @@ export const buildProject = async (
2626
);
2727
}
2828

29+
function determineDestinations(): string[] {
30+
if (args.destinations != undefined) {
31+
return args.destinations;
32+
}
33+
34+
if (args.device && typeof args.device === 'string') {
35+
// Check if the device argument looks like a UDID (assuming UDIDs are alphanumeric and have specific length)
36+
const isUDID = /^[A-Fa-f0-9-]{25,}$/.test(args.device);
37+
if (isUDID) {
38+
return [`id=${args.device}`];
39+
} else {
40+
// If it's a device name
41+
return [`name=${args.device}`];
42+
}
43+
}
44+
45+
if (args.catalyst) {
46+
return ['platform=macOS,variant=Mac Catalyst'];
47+
}
48+
49+
if (udid) {
50+
return [`id=${udid}`];
51+
}
52+
53+
if (configuration === 'Debug' || args.device) {
54+
return [`generic/platform=${simulatorDest}`];
55+
}
56+
57+
return [`generic/platform=${platformName}`];
58+
}
59+
60+
const destinations = determineDestinations().flatMap((destination) => [
61+
'-destination',
62+
destination,
63+
]);
64+
2965
const xcodebuildArgs = [
3066
xcodeProject.isWorkspace ? '-workspace' : '-project',
3167
xcodeProject.name,
@@ -34,28 +70,7 @@ export const buildProject = async (
3470
configuration,
3571
'-scheme',
3672
scheme,
37-
'-destination',
38-
(() => {
39-
if (args.device && typeof args.device === 'string') {
40-
// Check if the device argument looks like a UDID (assuming UDIDs are alphanumeric and have specific length)
41-
const isUDID = /^[A-Fa-f0-9-]{25,}$/.test(args.device);
42-
if (isUDID) {
43-
return `id=${args.device}`;
44-
} else {
45-
// If it's a device name
46-
return `name=${args.device}`;
47-
}
48-
}
49-
50-
return args.catalyst
51-
? 'platform=macOS,variant=Mac Catalyst'
52-
: udid
53-
? `id=${udid}`
54-
: configuration === 'Debug' || args.device
55-
? `generic/platform=${simulatorDest}`
56-
: `generic/platform=${platformName}` +
57-
(args.destination ? ',' + args.destination : '');
58-
})(),
73+
...destinations,
5974
];
6075

6176
if (args.archive) {

0 commit comments

Comments
 (0)