PaddlePaddle/PaddleOCR · error · SystemExit
xcresulttool export attachments failed with exit {r.returnco
Error message
xcresulttool export attachments failed with exit {r.returncode}. What it means
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.
Source
Thrown at deploy/ios_demo/scripts/extract_xcresult_attachments.py:279
out_path: Path,
) -> None:
with tempfile.TemporaryDirectory() as td:
r = _run(
[
"xcrun",
"xcresulttool",
"export",
"attachments",
"--path",
str(result_path),
"--test-id",
test_identifier,
"--output-path",
td,
]
)
if r.returncode != 0:
raise SystemExit(
_die(
f"xcresulttool export attachments failed with exit {r.returncode}.",
f"test-id={test_identifier}",
"Inspect stderr above.",
)
)
td_path = Path(td)
src = _pick_exported_file(td_path, wanted_out_name, stored_name)
if src is None or not src.is_file():
raise SystemExit(
_die(
f"Could not resolve exported file (wanted {wanted_out_name!r}, stored {stored_name!r}).",
f"export dir: {td}",
"Check `manifest.json` and `xcresulttool export attachments` stderr.",
)
)
out_path.parent.mkdir(parents=True, exist_ok=True)
shutil.move(str(src), str(out_path))View on GitHub (pinned to 2661c7c0ef)
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`.
Defensive patterns
Strategy: validation
Validate before calling
import json, subprocess
def test_id_exists(bundle: str, test_id: str) -> bool:
r = subprocess.run(
["xcrun", "xcresulttool", "get", "test-results", "tests", "--path", bundle],
capture_output=True, text=True,
)
if r.returncode != 0:
return False
return test_id in r.stdout Try / catch
try:
extract(bundle, test_id, name)
except SystemExit:
# stderr already carries xcresulttool's own error lines; inspect them before retrying
log.error("attachment export failed for test-id=%s", test_id)
raise Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Could not parse xcresulttool JSON: {e}.
- Could not resolve exported file (wanted {wanted_out_name!r},
- xcresulttool metrics export failed
- degenerate text crop (zero width/height)
- compare_ocr_json.py requires `pip install shapely`
AI-assisted analysis of PaddlePaddle/PaddleOCR@2661c7c0ef (2026-08-14).
Data as JSON: /api/errors/c4d615f0978b3988.
Report an issue: GitHub.