fix: 兼容新版 Xcode 的 AFNetworking 头文件
This commit is contained in:
@@ -17,6 +17,8 @@ from backend.services.build_service import (
|
||||
prepare_source_snapshot,
|
||||
build_project,
|
||||
generate_config,
|
||||
run_pod_install,
|
||||
_patch_afnetworking_private_headers,
|
||||
_cleanup_old_builds,
|
||||
_resolve_provisioning_profile,
|
||||
)
|
||||
@@ -206,6 +208,34 @@ async def test_copy_source_code_overwrites_existing(tmp_dirs, log_streamer):
|
||||
assert (result / "readoor").exists()
|
||||
|
||||
|
||||
def test_patch_afnetworking_private_headers(tmp_path):
|
||||
"""pod install 后移除新版 Xcode 禁止直接引用的 netinet6 私有头。"""
|
||||
source_dir = tmp_path / "Pods" / "AFNetworking" / "AFNetworking"
|
||||
source_dir.mkdir(parents=True)
|
||||
source_file = source_dir / "AFNetworkReachabilityManager.m"
|
||||
source_file.write_text(
|
||||
"#import <netinet/in.h>\n#import <netinet6/in6.h>\n#import <arpa/inet.h>\n"
|
||||
)
|
||||
source_file.chmod(0o444)
|
||||
|
||||
assert _patch_afnetworking_private_headers(tmp_path) == 1
|
||||
assert "#import <netinet6/in6.h>" not in source_file.read_text()
|
||||
assert "#import <netinet/in.h>" in source_file.read_text()
|
||||
assert source_file.stat().st_mode & 0o777 == 0o444
|
||||
|
||||
|
||||
async def test_run_pod_install_patches_afnetworking(tmp_path, log_streamer):
|
||||
source_dir = tmp_path / "Pods" / "AFNetworking"
|
||||
source_dir.mkdir(parents=True)
|
||||
source_file = source_dir / "AFHTTPSessionManager.m"
|
||||
source_file.write_text("#import <netinet6/in6.h>\n")
|
||||
|
||||
with patch("asyncio.create_subprocess_exec", return_value=_make_mock_process()):
|
||||
await run_pod_install("t1", tmp_path)
|
||||
|
||||
assert "netinet6/in6.h" not in source_file.read_text()
|
||||
|
||||
|
||||
async def test_build_project_passes_scheme_as_exec_argument(tmp_path, log_streamer):
|
||||
"""Scheme 中的 shell 特殊字符只能作为 xcodebuild 参数,不能被执行。"""
|
||||
build_dir = tmp_path / "build"
|
||||
|
||||
Reference in New Issue
Block a user