fix: 兼容新版 Xcode 的 AFNetworking 头文件

This commit is contained in:
shenlei
2026-07-20 14:37:04 +09:00
parent 2ad5f208ed
commit c209ae423c
2 changed files with 68 additions and 0 deletions
+38
View File
@@ -41,6 +41,37 @@ class BuildError(Exception):
source_prepare_lock = asyncio.Lock()
def _patch_afnetworking_private_headers(build_dir: Path) -> int:
"""移除旧版 AFNetworking 对 Xcode 新 SDK 私有头的直接引用。"""
afnetworking_dir = build_dir / "Pods" / "AFNetworking"
if not afnetworking_dir.is_dir():
return 0
private_import = "#import <netinet6/in6.h>"
patched_files = 0
for source_path in afnetworking_dir.rglob("*"):
if source_path.suffix not in {".h", ".m", ".mm"} or not source_path.is_file():
continue
content = source_path.read_text(encoding="utf-8")
if private_import not in content:
continue
updated_lines = [
line for line in content.splitlines(keepends=True)
if line.strip() != private_import
]
original_mode = source_path.stat().st_mode
try:
source_path.chmod(original_mode | 0o200)
source_path.write_text("".join(updated_lines), encoding="utf-8")
finally:
source_path.chmod(original_mode)
patched_files += 1
return patched_files
def _decode_provisioning_profile(profile_path: Path) -> dict:
"""沿用 AutoPacking 脚本的 security cms 方式读取描述文件。"""
try:
@@ -654,6 +685,13 @@ async def run_pod_install(task_id: str, build_dir: Path):
if process.returncode != 0:
raise BuildError("pod install 失败", category="config")
patched_files = await asyncio.to_thread(_patch_afnetworking_private_headers, build_dir)
if patched_files:
await log_streamer.emit(
task_id,
f"已修复 AFNetworking 私有头引用: {patched_files} 个文件",
)
await log_streamer.emit(task_id, "依赖安装完成")