Skip to content

fix in #130 broken on physical iOS device: runner receives Mac path and can't write to it #131

@nickdima

Description

@nickdima

Description

The fallback path introduced in #130 for physical iOS device screenshots is broken. When xcrun devicectl device screenshot fails (e.g. on Xcode 26.x), the code falls back to:

await runIosRunnerCommand(device, { command: 'screenshot', outPath });

The `outPath` here is the Mac output path (e.g. `/tmp/screenshot.png`). The Swift runner receives this and tries to write directly to that path on the iOS device:

try screenshot.pngRepresentation.write(to: URL(fileURLWithPath: requestedOutPath))

Since `/tmp` is not a writable path in an iOS app sandbox, this always fails with:

Error (COMMAND_FAILED): failed to write screenshot: You don't have permission to save the file "screenshot.png" in the folder "tmp".

Steps to Reproduce

agent-device open MyApp --platform ios  # physical device, Xcode 26.x
agent-device screenshot /tmp/output.png

Expected Behavior

Screenshot is saved to /tmp/output.png on the Mac.

Actual Behavior

Error (COMMAND_FAILED): failed to write screenshot: You don't have permission to save the file "output.png" in the folder "tmp".

Fix

The Swift runner should write to `NSTemporaryDirectory()` (which is writable) and return the device-local file path. The TypeScript daemon should then pull the file to the Mac using `xcrun devicectl device copy from` — the same pattern already used by the recording feature.

Environment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions