Skip to content

Commit 8822b4a

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 a414d98 commit 8822b4a

File tree

1 file changed

+15
-5
lines changed
  • packages/cli-platform-apple/src/commands/runCommand

1 file changed

+15
-5
lines changed

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

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -272,12 +272,22 @@ const createRun =
272272
}
273273

274274
if (args.udid) {
275-
const device = devices.find((d) => d.udid === args.udid);
275+
let device = devices.find((d) => d.udid === args.udid);
276276
if (!device) {
277-
return logger.error(
278-
`Could not find a device with udid: "${chalk.bold(
279-
args.udid,
280-
)}". ${printFoundDevices(devices)}`,
277+
// On arm64 machines, the catalyst UDID returned by 'xcrun xctrace list devices' is not correct
278+
// xcodebuild will return an error indicating the UDID is unknown and offering a different one
279+
// you may obtain it by running xcodebuild with the UDID you think works then parse out the other one from the returned error:
280+
// 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)
281+
//
282+
// How to handle the incorrect catalyst UDID?
283+
// Assume if a UDID is specified, the user knows what they are doing.
284+
// Use the given UDID and force the type, so "catalyst" will launch the app correctly
285+
device = {name: 'unknown', udid: args.udid, type: 'catalyst'};
286+
logger.warn(
287+
`Could not find a device with udid: "${chalk.bold(args.udid)}".`,
288+
);
289+
logger.warn(
290+
'Running with provided udid anyway, and type "catalyst". \'xcodebuild\' command may return error.',
281291
);
282292
}
283293
if (device.type === 'simulator') {

0 commit comments

Comments
 (0)