From 9d5ca7de87d0759654dbdf8f1b90e4b88ce8b40d Mon Sep 17 00:00:00 2001 From: Pascal Hartig Date: Fri, 30 Oct 2020 05:43:10 -0700 Subject: [PATCH] Support screencaps/recordings from multiple devices Summary: We've been using "booted" as a shortcut to select a device in `xcrun` but that will only refer to the *first* booted simulator. If you have multiple ones, that causes screenshots, videos and logs to always be pulled from the first. Of course, this isn't documented anywhere, because Apple, but you can instead of `booted` pass in the "UDID" and refer to a specific device in all cases. Reviewed By: nikoant Differential Revision: D24627077 fbshipit-source-id: 2a52a8a17776746af4b3f6ca821dcce37bb0f7c2 --- desktop/app/src/devices/IOSDevice.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/desktop/app/src/devices/IOSDevice.tsx b/desktop/app/src/devices/IOSDevice.tsx index 21a388d00..8498f36c4 100644 --- a/desktop/app/src/devices/IOSDevice.tsx +++ b/desktop/app/src/devices/IOSDevice.tsx @@ -58,7 +58,7 @@ export default class IOSDevice extends BaseDevice { const tmpFilePath = path.join(tmpDirectory, tmpImageName); const command = this.deviceType === 'emulator' - ? `xcrun simctl io booted screenshot ${tmpFilePath}` + ? `xcrun simctl io ${this.serial} screenshot ${tmpFilePath}` : `idb screenshot --udid ${this.serial} ${tmpFilePath}`; return promisify(exec)(command) .then(() => promisify(fs.readFile)(tmpFilePath)) @@ -68,7 +68,7 @@ export default class IOSDevice extends BaseDevice { } navigateToLocation(location: string) { - const command = `xcrun simctl openurl booted "${location}"`; + const command = `xcrun simctl openurl ${this.serial} "${location}"`; exec(command); } @@ -97,7 +97,7 @@ export default class IOSDevice extends BaseDevice { 'simctl', ...deviceSetPath, 'spawn', - 'booted', + this.serial, 'log', 'stream', '--style', @@ -185,7 +185,7 @@ export default class IOSDevice extends BaseDevice { async startScreenCapture(destination: string) { this.recordingProcess = exec( - `xcrun simctl io booted recordVideo --codec=h264 --force ${destination}`, + `xcrun simctl io ${this.serial} recordVideo --codec=h264 --force ${destination}`, ); this.recordingLocation = destination; }