Skip to content

Commit f0946ab

Browse files
committed
fix(apple): answer a developer disk image complaint with device support
One `devicectl` hint covered both "developer mode is disabled" and "developer disk image", and it named Developer Mode. That pairing runs one way only: a phone with the toggle off cannot mount the image either. The reverse is common — a device whose toggle is on, waiting for Xcode to finish installing device support — and people were sent to a Settings pane that was already correct while the actual wait went unmentioned. The two complaints are answered apart now. When the output names both, the toggle still wins, since it is the one that explains the other. #2683 adds the device's own reading of both states, which is what lets the tool-output path stop guessing which one it is looking at.
1 parent 2a05584 commit f0946ab

2 files changed

Lines changed: 43 additions & 5 deletions

File tree

‎packages/platform-apple/src/core/__tests__/devicectl.test.ts‎

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,31 @@ test('parseIosDeviceProcessesPayload maps running process entries', () => {
9898
]);
9999
});
100100

101-
test('resolveIosDevicectlHint points at Developer Mode when the disk image cannot mount', () => {
101+
test('resolveIosDevicectlHint names the developer disk image when that is all it reports', () => {
102102
// Observed on a freshly paired iPhone: unlocked, trusted, `available (paired)`
103-
// in Xcode, and still unusable because Developer Mode was off. The default
104-
// hint sent the user to re-check trust, which was already fine.
103+
// in Xcode, and still unusable. This line used to be answered with Developer
104+
// Mode advice, which is right often enough to survive as a guess and wrong
105+
// whenever Xcode simply has not finished installing device support on a phone
106+
// whose toggle is already on (#2683). The device reports both states apart, so
107+
// the hint answers the one the output named.
105108
const hint = resolveIosDevicectlHint(
106109
'',
107110
'Failed to launch iOS app: The developer disk image could not be mounted on this device. (com.apple.dt.CoreDeviceError error 12040 (0x2F08))',
108111
);
109112

113+
assert.match(String(hint), /device support/i);
114+
assert.doesNotMatch(String(hint), /Developer Mode/);
115+
});
116+
117+
test('resolveIosDevicectlHint names Developer Mode when the output says both', () => {
118+
// The pairing this hint was written for: a phone with the toggle off cannot
119+
// mount the image either, so the toggle is the thing to fix and the direction
120+
// that genuinely holds (#2683).
121+
const hint = resolveIosDevicectlHint(
122+
'',
123+
'The operation failed because Developer Mode is disabled. The developer disk image could not be mounted on this device.',
124+
);
125+
110126
assert.match(String(hint), /Developer Mode/);
111127
assert.match(String(hint), /Privacy & Security/);
112128
});

‎packages/platform-apple/src/core/devicectl.ts‎

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,21 @@ export const IOS_DEVICECTL_DEFAULT_HINT =
343343
const IOS_DEVICE_PROCESS_LIST_HINT =
344344
"This Xcode/CoreDevice toolchain must support 'devicectl device info processes' with JSON runningProcesses so agent-device can resolve app process IDs. Inspect diagnostics for the exact devicectl API failure.";
345345

346+
/**
347+
* The answer for a device whose own Developer Mode toggle is off (#2683). The device fact publishes
348+
* this same string, so the tool-output path and the device path cannot drift apart.
349+
*/
350+
const IOS_DEVICE_DEVELOPER_MODE_OFF_HINT =
351+
'Enable Developer Mode on the iOS device (Settings > Privacy & Security > Developer Mode), restart it when prompted, unlock it, then retry.';
352+
353+
/**
354+
* The answer for a developer disk image complaint on its own (#2683). It is deliberately not a
355+
* Developer Mode answer: a device can have the toggle on and still be waiting for Xcode to install
356+
* device support, and sending someone to a setting that is already correct loses the actual cause.
357+
*/
358+
const IOS_DEVICE_DEVELOPER_DISK_IMAGE_HINT =
359+
'Let Xcode finish preparing this device: keep it unlocked and connected by cable, open Xcode > Settings > Platforms (or Window > Devices and Simulators), wait for device support to install, then retry.';
360+
346361
export function resolveIosDevicectlHint(stdout: string, stderr: string): string | null {
347362
const text = `${stdout}\n${stderr}`.toLowerCase();
348363
if (text.includes('device is busy') && text.includes('connecting')) {
@@ -356,8 +371,15 @@ export function resolveIosDevicectlHint(stdout: string, stderr: string): string
356371
// usual state of a phone that has never been used for development. The
357372
// default hint sends people to check trust and Xcode, none of which is wrong
358373
// yet none of which is the cause.
359-
if (text.includes('developer disk image') || text.includes('developer mode is disabled')) {
360-
return 'Enable Developer Mode on the iOS device (Settings > Privacy & Security > Developer Mode), restart it when prompted, unlock it, then retry.';
374+
//
375+
// The two complaints are answered apart (#2683): an image line by itself is not evidence that the
376+
// toggle is off, and the device reports both states directly, so the name of one is never used as
377+
// the name of the other.
378+
if (text.includes('developer mode is disabled')) {
379+
return IOS_DEVICE_DEVELOPER_MODE_OFF_HINT;
380+
}
381+
if (text.includes('developer disk image')) {
382+
return IOS_DEVICE_DEVELOPER_DISK_IMAGE_HINT;
361383
}
362384
if (text.includes('must be paired')) {
363385
return 'Pair the iOS device with this Mac: connect it by cable, unlock it, accept the Trust prompt, and enter the device passcode, then retry.';

0 commit comments

Comments
 (0)