fix: 本地 Pod 索引缺少所需版本时自动 --repo-update 重试
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
10c39b5116
commit
a9e169b00c
@@ -860,6 +860,27 @@ def _pod_dir(build_dir: Path, xcode: dict = None) -> Path:
|
||||
return None
|
||||
|
||||
|
||||
_POD_SPEC_MISSING = "Unable to find a specification for"
|
||||
|
||||
|
||||
async def _run_pod(task_id: str, pod_dir: Path, *extra_args: str) -> tuple:
|
||||
"""执行 pod install,实时输出日志,返回 (退出码, 输出行)。"""
|
||||
process = await asyncio.create_subprocess_exec(
|
||||
"pod", "install", *extra_args,
|
||||
cwd=str(pod_dir),
|
||||
stdout=asyncio.subprocess.PIPE,
|
||||
stderr=asyncio.subprocess.STDOUT,
|
||||
)
|
||||
output = []
|
||||
async for line in process.stdout:
|
||||
decoded = line.decode("utf-8", errors="replace").strip()
|
||||
if decoded:
|
||||
output.append(decoded)
|
||||
await log_streamer.emit(task_id, decoded)
|
||||
await process.wait()
|
||||
return process.returncode, output
|
||||
|
||||
|
||||
async def run_pod_install(task_id: str, build_dir: Path, xcode: dict = None):
|
||||
"""安装 CocoaPods 依赖"""
|
||||
await log_streamer.emit_step(task_id, "安装依赖")
|
||||
@@ -871,21 +892,13 @@ async def run_pod_install(task_id: str, build_dir: Path, xcode: dict = None):
|
||||
if pod_dir != build_dir:
|
||||
await log_streamer.emit(task_id, f"Podfile 目录: {pod_dir.relative_to(build_dir)}")
|
||||
|
||||
process = await asyncio.create_subprocess_exec(
|
||||
"pod", "install",
|
||||
cwd=str(pod_dir),
|
||||
stdout=asyncio.subprocess.PIPE,
|
||||
stderr=asyncio.subprocess.STDOUT,
|
||||
)
|
||||
returncode, output = await _run_pod(task_id, pod_dir)
|
||||
# 打包机本地的 Specs 索引过旧时找不到新版本 Pod,更新索引后重试一次
|
||||
if returncode != 0 and any(_POD_SPEC_MISSING in line for line in output):
|
||||
await log_streamer.emit(task_id, "本地 Pod 索引缺少所需版本,更新索引后重试(pod install --repo-update)", level="warn")
|
||||
returncode, output = await _run_pod(task_id, pod_dir, "--repo-update")
|
||||
|
||||
async for line in process.stdout:
|
||||
decoded = line.decode("utf-8", errors="replace").strip()
|
||||
if decoded:
|
||||
await log_streamer.emit(task_id, decoded)
|
||||
|
||||
await process.wait()
|
||||
|
||||
if process.returncode != 0:
|
||||
if returncode != 0:
|
||||
raise BuildError("pod install 失败", category="config")
|
||||
|
||||
patched_files = await asyncio.to_thread(_patch_afnetworking_private_headers, pod_dir)
|
||||
|
||||
Reference in New Issue
Block a user