Skip to content

Commit f702812

Browse files
committed
fix(macCatalyst): assume a provided UDID is valid
works around a problem where macCatalyst UDIDs are not correct when fetched from system, so attempting to find them in list of UDIDs always fails and macCatalyst apps will not start
1 parent 26dd51a commit f702812

File tree

1 file changed

+19
-9
lines changed
  • packages/cli-platform-apple/src/commands/runCommand

1 file changed

+19
-9
lines changed

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

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -310,15 +310,8 @@ const createRun =
310310
}
311311

312312
if (args.udid) {
313-
const device = devices.find((d) => d.udid === args.udid);
314-
if (!device) {
315-
return logger.error(
316-
`Could not find a device with udid: "${chalk.bold(
317-
args.udid,
318-
)}". ${printFoundDevices(devices)}`,
319-
);
320-
}
321-
if (device.type === 'simulator') {
313+
let device = devices.find((d) => d.udid === args.udid);
314+
if (device?.type === 'simulator') {
322315
return runOnSimulator(
323316
xcodeProject,
324317
platformName,
@@ -328,6 +321,23 @@ const createRun =
328321
fallbackSimulator,
329322
);
330323
} else {
324+
if (!device) {
325+
// On arm64 machines, the catalyst UDID returned by 'xcrun xctrace list devices' is not correct
326+
// xcodebuild will return an error indicating the UDID is unknown and offering a different one
327+
// you may obtain it by running xcodebuild with the UDID you think works then parse out the other one from the returned error:
328+
// CATALYST_DESTINATION=$(xcodebuild -workspace ios/rnfbdemo.xcworkspace -configuration Debug -scheme rnfbdemo -destination id=7153382A-C92B-5798-BEA3-D82D195F25F8 2>&1|grep macOS|grep Catalyst|head -1 |cut -d':' -f5 |cut -d' ' -f1)
329+
//
330+
// How to handle the incorrect catalyst UDID?
331+
// Assume if a UDID is specified, the user knows what they are doing.
332+
// Use the given UDID and force the type, so "catalyst" will launch the app correctly
333+
device = {name: 'unknown', udid: args.udid, type: 'catalyst'};
334+
logger.warn(
335+
`Could not find a device with udid: "${chalk.bold(args.udid)}".`,
336+
);
337+
logger.warn(
338+
'Running with provided udid anyway, and type "catalyst". \'xcodebuild\' command may return error.',
339+
);
340+
}
331341
return runOnDevice(
332342
device,
333343
platformName,

0 commit comments

Comments
 (0)