You need to enable JavaScript to run this app. Xcode 12.3运行测试遇arm64架构Undefined symbols错误求助
优惠活动
大模型
产品
解决方案
定价
更多

Xcode 12.3运行测试遇arm64架构Undefined symbols错误求助

Xcode 12.3 运行测试用例触发arm64架构链接错误的排查
  • 实际场景:使用Xcode 12.3运行项目测试用例时触发链接报错
  • 前期排查进展:此前查阅资料判断这类错误常和项目内冗余无关文件有关,逐文件排查后未定位到关联问题
  • 实际报错日志:
Undefined symbols for architecture arm64:
  "protocol descriptor for InTravel.URLRequestFactory", referenced from:
      l_got.$s8InTravel17URLRequestFactoryMp in Tests_RequestFactory.o
  "(extension in InTravel):InTravel.EndPointType.url.getter : Foundation.URL", referenced from:
      Tests_iOS.MockRequestFactory.createRequest(InTravel.EndPointType) throws -> Foundation.URLRequest in Tests_RequestFactory.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
  • 报错对应截图:
    报错截图

同类问题可落地解决方向

测试Target依赖配置排查
报错缺失的URLRequestFactory协议、EndPointType的url计算属性均为主App Target的编译产物,绝大多数同类问题来自测试Target的依赖配置不匹配:

  • 选中测试Target,打开General配置页,确认Frameworks, Libraries, and Embedded Content列表中已正确添加主App的Target依赖
  • 切换到测试Target的Build Phases配置页,检查Compile Sources列表,确认未将主App的URLRequestFactory.swift、EndPointType.swift等源文件重复加入测试Target的编译列表(重复编译会导致符号冲突引发链接错误)

架构编译规则匹配排查
报错指向arm64架构下符号缺失,和Xcode 12.3的默认架构编译策略强相关:

  • 分别选中主App Target和测试Target,进入Build Settings配置页
  • 找到Excluded Architectures项,确认Debug编译模式下没有将arm64加入排除列表
  • 清空本地Derived Data缓存,执行全量编译

类型访问级别排查
完成上述配置校验后,如果报错仍存在,检查缺失符号的访问修饰符:

  • 确认URLRequestFactory协议、EndPointType的扩展实现没有被标记为private或fileprivate
  • 跨Target引用的类型若为internal级别,需确认测试Target和主App Target的产品模块名完全一致,避免Swift模块隔离导致符号无法识别

内容的提问来源于stack exchange,提问作者Stanislav Lavruk

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.11.08 06:15:07