PaddlePaddle/PaddleOCR · error · SystemExit

Could not parse xcresulttool JSON: {e}.

Error message

Could not parse xcresulttool JSON: {e}.

What it means

Raised as SystemExit when `xcrun xcresulttool get test-results` exits 0 but its stdout is not valid JSON. The script parses the tool's stdout with json.loads to enumerate test cases, so any non-JSON text (warnings, prompts, corrupt bundle output) makes parsing fail. The _die helper prints the parse error, the .xcresult path, and tells you to re-run xcodebuild test.

Source

Thrown at deploy/ios_demo/scripts/extract_xcresult_attachments.py:112

            "tests",
            "--path",
            str(result_path),
            "--format",
            "json",
        ]
    )
    if r.returncode != 0:
        raise SystemExit(
            _die(
                f"xcresulttool get test-results failed with exit {r.returncode}.",
                str(result_path),
                "Confirm the .xcresult was produced by a completed `xcodebuild test`.",
            )
        )
    try:
        return json.loads(r.stdout or b"{}")
    except json.JSONDecodeError as e:
        raise SystemExit(
            _die(
                f"Could not parse xcresulttool JSON: {e}.",
                str(result_path),
                "Re-run xcodebuild test to regenerate the .xcresult.",
            )
        )


def _collect_test_case_urls(node: dict) -> List[str]:
    urls: List[str] = []
    if node.get("nodeType") == "Test Case":
        u = node.get("nodeIdentifierURL")
        if isinstance(u, str) and u.startswith("test://"):
            urls.append(u)
    for ch in node.get("children") or []:
        urls.extend(_collect_test_case_urls(ch))
    return urls

View on GitHub (pinned to 2661c7c0ef)

Solutions

  1. Re-run `xcodebuild test` to regenerate a complete .xcresult bundle, then retry the script.
  2. Verify the bundle manually: `xcrun xcresulttool get test-results tests --path <bundle>` and confirm the output is JSON.
  3. Confirm the selected Xcode (`xcode-select -p`) is the same version that produced the bundle; switch or regenerate if not.
  4. Check the bundle is a complete directory (not zipped/transferred partially) and re-copy it if needed.
Defensive patterns

Strategy: validation

Validate before calling

import json, subprocess

def xcresult_tests_valid(bundle: str) -> bool:
    r = subprocess.run(
        ["xcrun", "xcresulttool", "get", "test-results", "tests", "--path", bundle],
        capture_output=True, text=True,
    )
    if r.returncode != 0:
        return False
    try:
        json.loads(r.stdout)
        return True
    except json.JSONDecodeError:
        return False

Try / catch

try:
    run_extract_script(bundle)
except SystemExit as e:
    # _die printed cause + next step to stderr; surface it, do not retry blindly
    log.error("xcresult extraction failed (exit %s); regenerate the bundle", e.code)
    raise

Prevention

When it happens

Trigger: Running extract_xcresult_attachments.py against an .xcresult that is corrupted, truncated, or produced by an incompatible Xcode version; xcresulttool printing a license/prompts/warnings to stdout before the JSON; passing a directory that is not a real .xcresult bundle.

Common situations: Xcode upgraded after the bundle was generated (xcresulttool format mismatch), CI copying the .xcresult without its full bundle structure, or xcodebuild test being interrupted so the result bundle is incomplete.

Related errors


AI-assisted analysis of PaddlePaddle/PaddleOCR@2661c7c0ef (2026-08-14). Data as JSON: /api/errors/1d364bb0691326b1. Report an issue: GitHub.