{"record":{"id":"c4d615f0978b3988","repo":"PaddlePaddle/PaddleOCR","slug":"xcresulttool-export-attachments-failed-with-exit","errorCode":null,"errorMessage":"xcresulttool export attachments failed with exit {r.returncode}.","messagePattern":"xcresulttool export attachments failed with exit (.+?)\\.","errorType":"console","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"deploy/ios_demo/scripts/extract_xcresult_attachments.py","lineNumber":279,"sourceCode":"    out_path: Path,\n) -> None:\n    with tempfile.TemporaryDirectory() as td:\n        r = _run(\n            [\n                \"xcrun\",\n                \"xcresulttool\",\n                \"export\",\n                \"attachments\",\n                \"--path\",\n                str(result_path),\n                \"--test-id\",\n                test_identifier,\n                \"--output-path\",\n                td,\n            ]\n        )\n        if r.returncode != 0:\n            raise SystemExit(\n                _die(\n                    f\"xcresulttool export attachments failed with exit {r.returncode}.\",\n                    f\"test-id={test_identifier}\",\n                    \"Inspect stderr above.\",\n                )\n            )\n        td_path = Path(td)\n        src = _pick_exported_file(td_path, wanted_out_name, stored_name)\n        if src is None or not src.is_file():\n            raise SystemExit(\n                _die(\n                    f\"Could not resolve exported file (wanted {wanted_out_name!r}, stored {stored_name!r}).\",\n                    f\"export dir: {td}\",\n                    \"Check `manifest.json` and `xcresulttool export attachments` stderr.\",\n                )\n            )\n        out_path.parent.mkdir(parents=True, exist_ok=True)\n        shutil.move(str(src), str(out_path))","sourceCodeStart":261,"sourceCodeEnd":297,"githubUrl":"https://github.com/PaddlePaddle/PaddleOCR/blob/2661c7c0ef5c613e8f93c6e93b2e052399f0f854/deploy/ios_demo/scripts/extract_xcresult_attachments.py#L261-L297","documentation":"Raised as SystemExit when `xcrun xcresulttool export attachments --path ... --test-id ...` returns a non-zero exit code. The script exports each test's attachments into a temp dir and aborts when the export fails, pointing you to the stderr captured above and the failing test-id.","triggerScenarios":"Passing a --test-id that does not exist in the bundle (stale or hand-edited identifier); a damaged .xcresult whose attachment payloads are missing; an Xcode/xcresulttool version that rejects the export options.","commonSituations":"Test identifiers containing spaces or special characters being mangled by shell quoting in wrappers; bundles moved across machines; Xcode point releases changing export attachment behavior.","solutions":["Read the stderr lines the script prints above the failure — they come directly from xcresulttool and name the real cause.","Confirm the test-id exists: `xcrun xcresulttool get test-results tests --path <bundle>` and compare with the reported test-id.","Regenerate the .xcresult with a fresh `xcodebuild test` run.","Verify the selected Xcode supports export attachments: `xcrun xcresulttool help export`."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import json, subprocess\n\ndef test_id_exists(bundle: str, test_id: str) -> bool:\n    r = subprocess.run(\n        [\"xcrun\", \"xcresulttool\", \"get\", \"test-results\", \"tests\", \"--path\", bundle],\n        capture_output=True, text=True,\n    )\n    if r.returncode != 0:\n        return False\n    return test_id in r.stdout","typeGuard":null,"tryCatchPattern":"try:\n    extract(bundle, test_id, name)\nexcept SystemExit:\n    # stderr already carries xcresulttool's own error lines; inspect them before retrying\n    log.error(\"attachment export failed for test-id=%s\", test_id)\n    raise","preventionTips":["Derive --test-id values from the bundle's tests JSON, never hand-type them.","Quote test identifiers containing spaces when wrapping the script in shell.","Pin the CI Xcode version so export attachments behavior stays stable."],"tags":["ios","xcodebuild","xcresult","attachments","cli"],"backgroundTag":null,"analyzedSha":"2661c7c0ef5c613e8f93c6e93b2e052399f0f854","analyzedAt":"2026-08-14T20:17:30.180Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}